public void CacheCallbackFailureWithInstrumentationDisabledDoesNotFireWmiEvent() { CachingInstrumentationListener listener = new CachingInstrumentationListener(instanceName, false, false, false, formatter); Exception exception = new Exception(exceptionMessage); using (WmiEventWatcher eventListener = new WmiEventWatcher(1)) { CacheCallbackFailureEventArgs args = new CacheCallbackFailureEventArgs(key, exception); listener.CacheCallbackFailed(null, args); eventListener.WaitForEvents(); Assert.AreEqual(0, eventListener.EventsReceived.Count); } }
public void CacheCallbackFailureWithInstrumentationDisabledDoesNotWriteToEventLog() { CachingInstrumentationListener listener = new CachingInstrumentationListener(instanceName, false, false, false, formatter); Exception exception = new Exception(exceptionMessage); CacheCallbackFailureEventArgs args = new CacheCallbackFailureEventArgs(errorMessage, exception); using (EventLog eventLog = GetEventLog()) { int eventCount = eventLog.Entries.Count; listener.CacheCallbackFailed(null, args); Assert.AreEqual(eventCount, eventLog.Entries.Count); } }
public void CacheCallbackFailureWithInstrumentationEnabledDoesWriteToEventLog() { CachingInstrumentationListener listener = new CachingInstrumentationListener(instanceName, false, true, false, formatter); Exception exception = new Exception(exceptionMessage); CacheCallbackFailureEventArgs args = new CacheCallbackFailureEventArgs(key, exception); using (EventLog eventLog = GetEventLog()) { int eventCount = eventLog.Entries.Count; listener.CacheCallbackFailed(null, args); Assert.AreEqual(eventCount + 1, eventLog.Entries.Count); Assert.IsTrue(eventLog.Entries[eventCount].Message.IndexOf(exceptionMessage) > -1); } }
public void CacheCallbackFailureWithInstrumentationEnabledDoesFireWmiEvent() { CachingInstrumentationListener listener = new CachingInstrumentationListener(instanceName, false, false, true, formatter); Exception exception = new Exception(exceptionMessage); using (WmiEventWatcher eventListener = new WmiEventWatcher(1)) { CacheCallbackFailureEventArgs args = new CacheCallbackFailureEventArgs(key, exception); listener.CacheCallbackFailed(null, args); eventListener.WaitForEvents(); Assert.AreEqual(1, eventListener.EventsReceived.Count); Assert.AreEqual("CacheCallbackFailureEvent", eventListener.EventsReceived[0].ClassPath.ClassName); Assert.AreEqual(key, eventListener.EventsReceived[0].GetPropertyValue("Key")); Assert.IsTrue(eventListener.EventsReceived[0].GetPropertyValue("ExceptionMessage").ToString().IndexOf(exceptionMessage) > -1); } }
public void CacheCallbackFailed(object sender, CacheCallbackFailureEventArgs args) { SaveEventArgs(args); }