public void EventSourceExistsWhenDistributedServiceFailure() { DistributorEventLogger eventLogger = new DistributorEventLogger(EventSourceName); eventLogger.LogServiceFailure("Failure", new Exception(), TraceEventType.Critical); Assert.IsTrue(EventLog.SourceExists(eventLogger.EventSource)); }
public void ServiceFailureWithExceptionWritesToEventLog() { DistributorEventLogger logger = new DistributorEventLogger(TestApplicationName); using (EventLog eventLog = GetEventLog()) { int eventCount = eventLog.Entries.Count; logger.LogServiceFailure(message, GetException(), TraceEventType.Error); Assert.AreEqual(eventCount + 1, eventLog.Entries.Count); } }
public void ServiceFailureWithoutExceptionWritesToEventLog() { DistributorEventLogger logger = new DistributorEventLogger(TestEventSource); using (var eventLog = new EventLogTracker(GetEventLog())) { logger.LogServiceFailure(message, null, TraceEventType.Error); Assert.AreEqual(1, eventLog.NewEntries().Count(ev => EventIsFromLogger(ev, logger))); } }
public void ServiceFailureWithExceptionFiresWmiEvent() { DistributorEventLogger logger = new DistributorEventLogger(TestApplicationName); using (WmiEventWatcher eventListener = new WmiEventWatcher(1)) { logger.LogServiceFailure(message, GetException(), TraceEventType.Error); eventListener.WaitForEvents(); Assert.AreEqual(1, eventListener.EventsReceived.Count); Assert.AreEqual("DistributorServiceFailureEvent", eventListener.EventsReceived[0].ClassPath.ClassName); Assert.IsTrue(((string)eventListener.EventsReceived[0].GetPropertyValue("FailureMessage")).StartsWith(message)); } }