public void GetMessageMustNotLogExceptionWhenExceptionIsNull() { DateTime now = DateTime.UtcNow; StubConsoleLoggerFormatter formatter = new StubConsoleLoggerFormatter(now); string message = formatter.GetMessage(nameof(ConsoleLoggerFormatterTests), LogLevel.Information, "Test", null); Assert.Matches($@"(?s)^{now:O} Information {nameof(ConsoleLoggerFormatterTests)} \[.*\] Test$", message); }
public void GetMessageMustLogExceptionWhenExceptionIsNotNull() { DateTime now = DateTime.UtcNow; StubConsoleLoggerFormatter formatter = new StubConsoleLoggerFormatter(now); string message = formatter.GetMessage(nameof(ConsoleLoggerFormatterTests), LogLevel.Information, "Test", new Exception("Test")); Assert.Matches($@"(?s)^{now:O} Information {nameof(ConsoleLoggerFormatterTests)} \[.*\] Test{Environment.NewLine}System.Exception: Test.*$", message); }