Class MoqLoggerCompatibility
Provides Moq-based logger verification and callback helpers used by the compatibility layer.
Inheritance
MoqLoggerCompatibility
Assembly: FastMoq.Provider.Moq.dll
Syntax
public static class MoqLoggerCompatibility
Methods
SetupLoggerCallback<TLogger>(Mock<TLogger>, Action<LogLevel, EventId, string, Exception?>)
Registers a callback that receives normalized logger invocations from a Moq logger mock.
Declaration
public static void SetupLoggerCallback<TLogger>(this Mock<TLogger> logger, Action<LogLevel, EventId, string, Exception?> callback) where TLogger : class, ILogger
Parameters
Type Parameters
VerifyLogger(Mock<ILogger>, LogLevel, string, Exception?, int?, int)
Verifies a non-generic logger mock was written with the expected exception payload.
Declaration
public static void VerifyLogger(this Mock<ILogger> loggerMock, LogLevel logLevel, string message, Exception? exception, int? eventId = null, int times = 1)
Parameters
VerifyLogger(Mock<ILogger>, LogLevel, string, int)
Verifies a non-generic logger mock was written to the expected number of times.
Declaration
public static void VerifyLogger(this Mock<ILogger> loggerMock, LogLevel logLevel, string message, int times = 1)
Parameters
VerifyLogger<TException>(Mock<ILogger>, LogLevel, string, TException?, int?, Times)
Verifies a non-generic logger mock using an exception type-specific matcher and a Moq Moq.Times constraint.
Declaration
public static void VerifyLogger<TException>(this Mock<ILogger> loggerMock, LogLevel logLevel, string message, TException? exception, int? eventId, Times times) where TException : Exception
Parameters
| Type |
Name |
Description |
| Mock<ILogger> |
loggerMock |
|
| LogLevel |
logLevel |
|
| string |
message |
|
| TException |
exception |
|
| int? |
eventId |
|
| Times |
times |
|
Type Parameters
| Name |
Description |
| TException |
|
VerifyLogger<TException>(Mock<ILogger>, LogLevel, string, TException?, int?, Func<Times>)
Verifies a non-generic logger mock using an exception type-specific matcher and a deferred Moq Moq.Times constraint.
Declaration
public static void VerifyLogger<TException>(this Mock<ILogger> loggerMock, LogLevel logLevel, string message, TException? exception, int? eventId, Func<Times> times) where TException : Exception
Parameters
Type Parameters
| Name |
Description |
| TException |
|
VerifyLogger<TException>(Mock<ILogger>, LogLevel, string, TException?, int?, int)
Verifies a non-generic logger mock using an exception type-specific matcher and an exact call count.
Declaration
public static void VerifyLogger<TException>(this Mock<ILogger> loggerMock, LogLevel logLevel, string message, TException? exception, int? eventId = null, int times = 1) where TException : Exception
Parameters
Type Parameters
| Name |
Description |
| TException |
|
VerifyLogger<TLogger>(Mock<TLogger>, LogLevel, string, Exception?, int?, int)
Verifies a generic logger mock was written with the expected exception payload.
Declaration
public static void VerifyLogger<TLogger>(this Mock<TLogger> loggerMock, LogLevel logLevel, string message, Exception? exception, int? eventId = null, int times = 1) where TLogger : class, ILogger
Parameters
Type Parameters
VerifyLogger<TLogger>(Mock<TLogger>, LogLevel, string, int)
Verifies a generic logger mock was written to the expected number of times.
Declaration
public static void VerifyLogger<TLogger>(this Mock<TLogger> loggerMock, LogLevel logLevel, string message, int times = 1) where TLogger : class, ILogger
Parameters
| Type |
Name |
Description |
| Mock<TLogger> |
loggerMock |
|
| LogLevel |
logLevel |
|
| string |
message |
|
| int |
times |
|
Type Parameters
VerifyLogger<TException, TLogger>(Mock<TLogger>, LogLevel, string, TException?, int?, int)
Verifies a generic logger mock using an exception type-specific matcher and an exact call count.
Declaration
public static void VerifyLogger<TException, TLogger>(this Mock<TLogger> loggerMock, LogLevel logLevel, string message, TException? exception, int? eventId = null, int times = 1) where TException : Exception where TLogger : class, ILogger
Parameters
| Type |
Name |
Description |
| Mock<TLogger> |
loggerMock |
|
| LogLevel |
logLevel |
|
| string |
message |
|
| TException |
exception |
|
| int? |
eventId |
|
| int |
times |
|
Type Parameters
| Name |
Description |
| TException |
|
| TLogger |
|