NSubstitute: How to unit test LoggerMessageAttribute?

41 Views Asked by At

Previously I was logging with LogWarning and had tests like this:

var logger = Substitute.For<ILogger>();
// Do stuff...
logger.Received(1).Log(LogLevel.Warning, 0, Arg.Any<AnyType>(), null, Arg.Any<Func<AnyType, Exception?, string>>());

But since EventLogLogger is obsolete. I should use LoggerMessageAttribute.

How can I test, that logger was logging?

0

There are 0 best solutions below