Пример #1
0
        public void EmitInternalMessages()
        {
            TraceListenerCounter listTraceListener = new TraceListenerCounter();

            Trace.Listeners.Clear();
            Trace.Listeners.Add(listTraceListener);
            LogLog.Error(GetType(), "Hello");
            LogLog.Error(GetType(), "World");
            Trace.Flush();
            Assert.AreEqual(2, listTraceListener.Count);

            try
            {
                LogLog.EmitInternalMessages = false;

                LogLog.Error(GetType(), "Hello");
                LogLog.Error(GetType(), "World");

                // 这里依然是两个消息,说明没有输出
                Assert.AreEqual(2, listTraceListener.Count);
            }
            finally
            {
                LogLog.EmitInternalMessages = true;
            }
        }
Пример #2
0
        public void TraceListenerCounterTest()
        {
            TraceListenerCounter listTraceListener = new TraceListenerCounter();

            Trace.Listeners.Clear();
            Trace.Listeners.Add(listTraceListener);

            Trace.Write("Hello");
            Trace.Write("World");

            Assert.AreEqual(2, listTraceListener.Count);
        }