public void ShouldAlwaysIncludeClientMachineNameInLogEntry() { // Given var mockLogWritter = new Mock <LogWriter>(); var logger = new EntLibLogger(mockLogWritter.Object); const string TestMessage = "This is test error message"; LogEntry logEntry = null; // When mockLogWritter.Setup(x => x.Write(It.IsAny <LogEntry>())).Callback((LogEntry le) => { logEntry = le; }); logger.Error(TestMessage); // Then logEntry.Should().Not.Be.Null(); logEntry.ExtendedProperties.ContainsKey("Client Machine Name").Should().Be.True(); }
public void ShouldAlwaysAddMessageToLogEntry() { // Given var mockLogWritter = new Mock <LogWriter>(); var logger = new EntLibLogger(mockLogWritter.Object); const string TestMessage = "This is test error message"; LogEntry logEntry = null; // When mockLogWritter.Setup(x => x.Write(It.IsAny <LogEntry>())).Callback((LogEntry le) => { logEntry = le; }); logger.Error(TestMessage); // Then logEntry.Should().Not.Be.Null(); logEntry.Message.Should().Not.Be.NullOrEmpty(); logEntry.Message.Should().Be(TestMessage); }