public void LoggerClearsEvents() { CapturingLoggerFactoryAdapter adapter = new CapturingLoggerFactoryAdapter(); CapturingLogger testLogger = (CapturingLogger)adapter.GetLogger("test"); testLogger.Trace("message1"); testLogger.Trace("message2"); Assert.IsNotNull(testLogger.LastEvent); Assert.AreEqual(2, testLogger.LoggerEvents.Count); testLogger.ClearLastEvent(); Assert.IsNull(testLogger.LastEvent); testLogger.Clear(); Assert.IsNull(testLogger.LastEvent); Assert.AreEqual(0, testLogger.LoggerEvents.Count); }
public void LoggerCapturesIndividualEvents() { CapturingLoggerFactoryAdapter adapter = new CapturingLoggerFactoryAdapter(); CapturingLogger testLogger = (CapturingLogger)adapter.GetLogger("test"); testLogger.Trace("message1"); testLogger.Trace("message2"); Assert.AreEqual(2, testLogger.LoggerEvents.Count); Assert.AreEqual("message2", testLogger.LastEvent.MessageObject); Assert.AreEqual("message1", testLogger.LoggerEvents[0].MessageObject); Assert.AreEqual("message2", testLogger.LoggerEvents[1].MessageObject); testLogger.ClearLastEvent(); Assert.IsNull(testLogger.LastEvent); testLogger.Clear(); Assert.IsNull(testLogger.LastEvent); Assert.AreEqual(0, testLogger.LoggerEvents.Count); }