public void debug_with_exception() { var sut = new BaseLoggerWrapper(GetType()); sut.Debug("Hello", new ExternalException()); Assert.AreEqual(sut.Entries.Count, 1); Assert.AreEqual(sut.Entries[0].Message, "Hello"); Assert.AreEqual(sut.Entries[0].LogLevel, LogLevel.Debug); Assert.IsInstanceOfType(sut.Entries[0].Exception, typeof(ExternalException)); }
public void debug_without_exception() { var sut = new BaseLoggerWrapper(GetType()); sut.Debug("Hello"); Assert.AreEqual(sut.Entries.Count, 1); Assert.AreEqual(sut.Entries[0].Message, "Hello"); Assert.AreEqual(sut.Entries[0].LogLevel, LogLevel.Debug); Assert.AreEqual(sut.Entries[0].Exception, null); }
public void debug_formatted() { var sut = new BaseLoggerWrapper(GetType()); sut.Debug("Hello {0}", "World"); Assert.AreEqual(sut.Entries.Count, 1); Assert.AreEqual(sut.Entries[0].Message, "Hello World"); Assert.AreEqual(sut.Entries[0].LogLevel, LogLevel.Debug); Assert.AreEqual(sut.Entries[0].Exception, null); }
public void info_without_exception() { var sut = new BaseLoggerWrapper(GetType()); sut.Info("Hello"); Assert.AreEqual(sut.Entries.Count, 1); Assert.AreEqual(sut.Entries[0].Message, "Hello"); Assert.AreEqual(sut.Entries[0].LogLevel, LogLevel.Info); Assert.AreEqual(sut.Entries[0].Exception, null); }
public void format_a_simple_exception() { try { var exception = new NotImplementedException(); var sut = new BaseLoggerWrapper(GetType()); var actual = sut.FormatException(exception); Assert.AreEqual(actual.StartsWith(" System.NotImplementedException"), true); Assert.Fail("no exception thrown"); } catch (Exception ex) { Assert.IsTrue(ex is Exception); } }
public void ignore_null_properties_in_the_exception_output() { try { var exception = new ExceptionWithProperty2() { UserId = 10 }; var sut = new BaseLoggerWrapper(GetType()); var actual = sut.FormatException(exception); Assert.AreEqual(actual.StartsWith(" MicroServer.Tests.Logging.Loggers.ExceptionWithProperty2"), true); Assert.AreEqual(actual.EndsWith("[UserId='10']\r\n"), true); } catch (Exception ex) { Assert.IsTrue(ex is Exception); } }
public void include_properties_in_the_exception_output() { try { var exception = new ExceptionWithProperty2() { UserId = 10, FirstName = "Arne" }; var sut = new BaseLoggerWrapper(GetType()); var actual = sut.FormatException(exception); Debug.WriteLine(actual.ToString()); Assert.AreEqual(actual.StartsWith(" MicroServer.Tests.Logging.Loggers.ExceptionWithProperty2"), true); Assert.AreEqual(actual.EndsWith("[UserId='10',FirstName='Arne']\r\n"), true); } catch (Exception ex) { Assert.IsTrue(ex is Exception); } }