Exemplo n.º 1
0
        public void EventLogWrittenWhenDeliveryToErrorSourceFails()
        {
            TraceListener badTraceListener = new BadTraceListener(new Exception("test exception"));
            LogSource     badSource        = new LogSource("badSource");

            badSource.Listeners.Add(badTraceListener);

            Dictionary <string, LogSource> logSources = new Dictionary <string, LogSource>();

            logSources.Add("foo", badSource);

            ILoggingInstrumentationProvider instrumentationProvider = new LoggingInstrumentationProvider(false, true, "applicationInstanceName");
            LogWriter writer = new LogWriterImpl(new List <ILogFilter>(), logSources, badSource, "foo", instrumentationProvider);

            writer.Write(CommonUtil.GetDefaultLogEntry());

            string lastEventLogEntry = CommonUtil.GetLastEventLogEntry();

            Assert.IsTrue(-1 != lastEventLogEntry.IndexOf("test exception"));
        }