public void EventLogLogger_InfoLevel_EventLogEntryTypeUsedTest() { //Arrange var messages = new List <Tuple <string, string, EventLogEntryType> >(); var logger = new EventLogLogger("Test") { WriteEntryToEventLog = (x, y, z) => messages.Add(new Tuple <string, string, EventLogEntryType>(x, y, z)) }; var testMessage = "Test message"; var testException = new Exception("Test"); //Act logger.IsInfoEnabled = true; logger.Info(testMessage); logger.Info(testException); logger.Info(testMessage, testException); //Assert Assert.AreEqual(3, messages.Select(x => x).Count(x => x.Item3 == EventLogEntryType.Information)); }
private static void TestEventLog() { EventLogLogger eventLog = new EventLogLogger(new LogMessageFactory()); eventLog.Warn("test ojej"); eventLog.Fatal("test ojej 2"); eventLog.Info("test ojej 3"); eventLog.Dispose(); }
public void EventLogLogger_InfoLog_MessageExposedTest() { //Arrange var messages = new List <Tuple <LogLevel, string, Exception> >(); var logger = new EventLogLogger("Test"); logger.IsInfoEnabled = true; logger.LogMessageHandler += (x, y, z) => messages.Add(new Tuple <LogLevel, string, Exception>(x, y, z)); var testMessage = "Test message"; var testException = new Exception("Test"); //Act logger.Info(testMessage); logger.Info(testException); logger.Info(testMessage, testException); //Assert Assert.AreEqual(3, messages.Count); Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, testMessage, null), messages[0], "Log entry with message was not exposed correctly."); Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, string.Empty, testException), messages[1], "Log entry with exception was not exposed correctly."); Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, testMessage, testException), messages[2], "Log entry with message and exception was not exposed correctly."); }