-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve ILogger from a logger factory #126
Comments
That would be great! Or make it opt-in like this for example: mocker.AddLoggerMocks(); |
I have no idea why I suggested this. What would the benefit be to get a logger this way rather than just the mock? |
Maybe its an issue that the loggermock returns null for the methods (e.g. beginscope) - 》crashes. Note: Most of the time there is no need to assert the loggermock. Personally I create a (generic) spy when we need to assert the logger. The ilogger is hard to verify due to the extensions and conversions. |
Well, I wish this wasn't closed. It's the closest thing I've found to what I'm trying to do. I want to NOT mock ILogger. I want to call Mocker.Use and register the open generic logger type with a lambda so that it uses an existing LoggerFactory to create a real logger to be injected during my tests at runtime. Why? So that I can see what happened during the test. I want to call CreateInstance to get my system under test, and I'd like it to use a real Logger. I just want a callback/lambda to specify it so that I can resolve the generic at runtime. |
I think I understand what you're describing b/c I do something similar by setting up a console logger for my unit tests. This may work for your use-case.
|
I'm thinking of something like this being added to the built-in resolvers.
The text was updated successfully, but these errors were encountered: