Exemplo n.º 1
0
        public void MemoryRecordsTraceEventSentDirectly()
        {
            var listener = new InMemoryTraceListener();

            listener.TraceEvent(null, "Source", TraceEventType.Warning, 1, "{0}-{1}", 2, "A");

            var events = listener.GetEvents();

            Assert.AreEqual(1, events.Length);

            Assert.AreEqual("Source", events[0].Source);
            Assert.AreEqual(1, events[0].Id);
            Assert.AreEqual("2-A", events[0].Message);
        }
Exemplo n.º 2
0
        public void MemoryOverwriteWhenMoreTracesThanLimit()
        {
            var listener = new InMemoryTraceListener(6);

            for (var count = 1; count <= 15; count++)
            {
                listener.TraceEvent(null, "Source", TraceEventType.Warning, count, "");
            }

            var events = listener.GetEvents();

            Assert.AreEqual(6, events.Length);

            Assert.AreEqual(10, events[0].Id);
            Assert.AreEqual(15, events[5].Id);
        }