Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }