Пример #1
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);
        }
Пример #2
0
        public void EmitInternalMessages()
        {
            TraceListenerCounter listTraceListener = new TraceListenerCounter();

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

            try {
                LogInternal.InternalMessage = false;

                LogInternal.Error(GetType(), "Hello");
                LogInternal.Error(GetType(), "World");
                Assert.AreEqual(2, listTraceListener.Count);
            } finally {
                LogInternal.InternalMessage = true;
            }
        }