adrianiftode / Moq.ILogger

Easy verify ILogger Moq mocks
Apache License 2.0
66 stars 7 forks source link

Ability to assert *not* logged message? #13

Closed brandonh-msft closed 1 year ago

brandonh-msft commented 1 year ago

Looking to try and assert that a specific type/message was not logged - any capability for this?

e.g. if I run a method and expect everything to succeed, I want to ensure no LogWarning or LogErrors were sent during that execution.

brandonh-msft commented 1 year ago

Ah, found VerifyNoOtherCalls just now. So I suppose the way to accomplish what I want is to run the successful path, assert any Information, Trace, Debug lines I know will come through, then throw this API after those. 👍🏻

brandonh-msft commented 1 year ago

Actually, no, I think I would like something like this - otherwise I am forced to constantly add any new non-X lines to my UT just to ensure no X lines were logged.

adrianiftode commented 1 year ago

Maybe I didn't understand well the issue, but isn't the Moq way of using the right approach?

loggerMock.VerifyLog(logger => logger.LogError("Some error"), Times.Never);
brandonh-msft commented 1 year ago

Thanks - been a while since I've used Moq and it's changed a lot but this appears to be what I'm after!

adrianiftode commented 1 year ago

Np, thank you too, that was the goal of this library, to re-use Moq's features and not to re-create a simple wrapper over Moq.