Using the Moq framework, it's non-trivial in some cases to verify "Did my logger actually log X message?" The first important note is you can't use Moq on extension methods, so you can't directly check LogWarning
for example. The workaround is to mock the method that the extension method calls..
For example, I want to verify that LogWarning(mymsg)
was logged, but LogWarning
is an extension method. So instead of checking that LogWarning
was called, we check that Log
was called because LogWarning eventually calls Log.
Finally, this SO post showed me how to verify that specific message was l