示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
 }