You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I've been trying to verify if my .NET Core 3 ILogger mock has been called in my Assert phase, and the following successfully throws if my test method logs an error or a critical:
_weatherLoggerMock.Verify(logger => logger.Log(
It.IsIn(new LogLevel[] { LogLevel.Error, LogLevel.Critical }),
It.IsAny<EventId>(),
It.IsAny<It.IsAnyType>(),
It.IsAny<Exception>(),
It.Is<Func<It.IsAnyType, Exception, string>>((v,t) => true)
), Times.Never(), "Logger was called with Error or Critical!");
However, the following doesn't throw:
_weatherLoggerMock.Verify(logger => logger.Log(
It.IsIn(new LogLevel[] { LogLevel.Error, LogLevel.Critical }),
It.IsAny<EventId>(),
It.IsAny<It.IsAnyType>(),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception, string>>()
), Times.Never(), "Logger was called with Error or Critical!");
Is this correct behaviour? It looks like the two should be semantically identical; in both cases I'm saying that the parameter should match the given type, and match no matter what the value. Why doesn't IsAny match?
The text was updated successfully, but these errors were encountered:
So I've been trying to verify if my .NET Core 3
ILogger
mock has been called in my Assert phase, and the following successfully throws if my test method logs an error or a critical:However, the following doesn't throw:
Is this correct behaviour? It looks like the two should be semantically identical; in both cases I'm saying that the parameter should match the given type, and match no matter what the value. Why doesn't
IsAny
match?The text was updated successfully, but these errors were encountered: