GetCallCount() public method

Gets the number of times any of the public methods on this instance were called.
public GetCallCount ( Method group ) : int
group Method
return int
Ejemplo n.º 1
0
        public void WriteIf1Test()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.WriteIf(false, (Object)"Message");
            Assert.Equal(0, listener.GetCallCount(Method.Write));
            Trace.WriteIf(true, (Object)"Message");
            Assert.Equal(1, listener.GetCallCount(Method.Write));
        }
Ejemplo n.º 2
0
        public void WriteLineIf4Test()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.WriteLineIf(false, "Message", "Category");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Trace.WriteLineIf(true, "Message", "Category");
            Assert.Equal(1, listener.GetCallCount(Method.WriteLine));
        }
Ejemplo n.º 3
0
        public void FailTest()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Fail("Text");
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
            Trace.Fail("Text", "Detail");
            Assert.Equal(2, listener.GetCallCount(Method.Fail));
        }
Ejemplo n.º 4
0
        public void TraceData()
        {
            var trace    = new TraceSource("TestTraceSource", SourceLevels.All);
            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.TraceData(TraceEventType.Verbose, 0, null);
            Assert.Equal(1, listener.GetCallCount(Method.TraceData));
            trace.TraceData(TraceEventType.Verbose, 0, "Data1", 2);
            Assert.Equal(2, listener.GetCallCount(Method.TraceData));
        }
Ejemplo n.º 5
0
        public void TraceInformation()
        {
            var trace    = new TraceSource("TestTraceSource", SourceLevels.All);
            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.TraceInformation(null);
            Assert.Equal(0, listener.GetCallCount(Method.TraceData));
            Assert.Equal(0, listener.GetCallCount(Method.Write));
            Assert.Equal(1, listener.GetCallCount(Method.TraceEvent));
        }
Ejemplo n.º 6
0
        public void Assert1Test()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Assert(true);
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(0, listener.GetCallCount(Method.Fail));
            Trace.Assert(false);
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
        }
Ejemplo n.º 7
0
        public void FailTest()
        {
            var listener = new TestTraceListener();

            // We have to clear the listeners list on Trace since there is a trace listener by default with AssertUiEnabled = true in Desktop and that will pop up an assert window with Trace.Fail
            Trace.Listeners.Clear();
            Trace.Listeners.Add(listener);
            Trace.Fail("Text");
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
            Trace.Fail("Text", "Detail");
            Assert.Equal(2, listener.GetCallCount(Method.Fail));
        }
Ejemplo n.º 8
0
        public void TraceEvent()
        {
            var trace    = new TraceSource("TestTraceSource", SourceLevels.All);
            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.TraceEvent(TraceEventType.Verbose, 0);
            Assert.Equal(1, listener.GetCallCount(Method.TraceEvent));
            trace.TraceEvent(TraceEventType.Verbose, 0, "Message");
            Assert.Equal(2, listener.GetCallCount(Method.TraceEvent));
            trace.TraceEvent(TraceEventType.Verbose, 0, "Format {0}", "arg0", 1);
            Assert.Equal(3, listener.GetCallCount(Method.TraceEvent));
        }
Ejemplo n.º 9
0
        public void Assert1Test()
        {
            var listener = new TestTraceListener();

            // We have to clear the listeners list on Trace since there is a trace listener by default with AssertUiEnabled = true in Desktop and that will pop up an assert window with Trace.Fail
            Trace.Listeners.Clear();
            Trace.Listeners.Add(listener);
            Trace.Assert(true);
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(0, listener.GetCallCount(Method.Fail));
            Trace.Assert(false);
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
        }
Ejemplo n.º 10
0
        public void WriteObjectTest()
        {
            var listener = new TestTraceListener();
            listener.Filter = new TestTraceFilter(false);
            listener.Write((Object)"Message");
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Filter = new TestTraceFilter(true);

            listener.Write((Object)null);
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Write((Object)"Message");
            Assert.Equal(1, listener.GetCallCount(Method.Write));
        }
Ejemplo n.º 11
0
        public void WriteObjectTest()
        {
            var listener = new TestTraceListener();

            listener.Filter = new TestTraceFilter(false);
            listener.Write((Object)"Message");
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Filter = new TestTraceFilter(true);

            listener.Write((Object)null);
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Write((Object)"Message");
            Assert.Equal(1, listener.GetCallCount(Method.Write));
        }
Ejemplo n.º 12
0
        public void CloseTest()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Close();
            Assert.Equal(1, listener.GetCallCount(Method.Dispose));
        }
Ejemplo n.º 13
0
        public void WriteLineObjectTest()
        {
            var listener = new TestTraceListener();

            listener.Filter = new TestTraceFilter(false);
            listener.WriteLine((Object)"Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));

            listener.Filter = new TestTraceFilter(true);

            // NOTE: Writing null will result in a newline being written
            listener.WriteLine((Object)null);
            Assert.Equal(1, listener.GetCallCount(Method.WriteLine));

            listener.WriteLine((Object)"Message");
            Assert.Equal(2, listener.GetCallCount(Method.WriteLine));
        }
Ejemplo n.º 14
0
        public void Assert2Test()
        {
            var listener = new TestTraceListener();
            var text     = new TestTextTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Listeners.Add(text);
            Trace.Assert(true, "Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(0, listener.GetCallCount(Method.Fail));
            text.Flush();
            Assert.DoesNotContain("Message", text.Output);
            Trace.Assert(false, "Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
            text.Flush();
            Assert.Contains("Message", text.Output);
        }
Ejemplo n.º 15
0
        public void SwitchLevelTest(SourceLevels sourceLevel, TraceEventType messageLevel, int expected)
        {
            var trace    = new TraceSource("TestTraceSource");
            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.Switch.Level = sourceLevel;
            trace.TraceEvent(messageLevel, 0);
            Assert.Equal(expected, listener.GetCallCount(Method.TraceEvent));
        }
Ejemplo n.º 16
0
        public void WriteCategoryTest()
        {
            var listener = new TestTraceListener();

            listener.Filter = new TestTraceFilter(false);
            listener.Write("Message", "Category");
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Filter = new TestTraceFilter(true);

            listener.Write("Message", null);
            Assert.Equal(1, listener.GetCallCount(Method.Write));

            listener.Write("Message", "Category");
            Assert.Equal(2, listener.GetCallCount(Method.Write));

            listener.Write(null, "Category");
            Assert.Equal(3, listener.GetCallCount(Method.Write));
        }
Ejemplo n.º 17
0
        public void Assert2Test()
        {
            var listener = new TestTraceListener();
            var text     = new TestTextTraceListener();

            // We have to clear the listeners list on Trace since there is a trace listener by default with AssertUiEnabled = true in Desktop and that will pop up an assert window with Trace.Fail
            Trace.Listeners.Clear();
            Trace.Listeners.Add(listener);
            Trace.Listeners.Add(text);
            Trace.Assert(true, "Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(0, listener.GetCallCount(Method.Fail));
            text.Flush();
            Assert.DoesNotContain("Message", text.Output);
            Trace.Assert(false, "Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
            Assert.Equal(1, listener.GetCallCount(Method.Fail));
            text.Flush();
            Assert.Contains("Message", text.Output);
        }
Ejemplo n.º 18
0
 public void TraceInformationTest()
 {
     var trace = new TraceSource("TestTraceSource", SourceLevels.All);
     var listener = new TestTraceListener();
     trace.Listeners.Add(listener);
     trace.TraceInformation("message");
     Assert.Equal(0, listener.GetCallCount(Method.TraceData));
     Assert.Equal(0, listener.GetCallCount(Method.Write));
     Assert.Equal(1, listener.GetCallCount(Method.TraceEvent));
     trace.TraceInformation("format", "arg1", "arg2");
     Assert.Equal(2, listener.GetCallCount(Method.TraceEvent));
 }
Ejemplo n.º 19
0
        public void CloseTest()
        {
            var trace = new TraceSource("T1", SourceLevels.All);
            trace.Listeners.Clear();

            var listener = new TestTraceListener();
            trace.Listeners.Add(listener);
            trace.Close();
            // NOTE: this assertion fails on .net 4.5
            // where TraceSource.Close calls TraceListener.Close, not Dispose.
            Assert.Equal(1, listener.GetCallCount(Method.Dispose));
            // Assert that writing to a closed TraceSource is not an error.
            trace.TraceEvent(TraceEventType.Critical, 0);
        }
Ejemplo n.º 20
0
        public void CloseTest()
        {
            var trace = new TraceSource("T1", SourceLevels.All);

            trace.Listeners.Clear();

            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.Close();
            Assert.Equal(1, listener.GetCallCount(Method.Close));
            // Assert that writing to a closed TraceSource is not an error.
            trace.TraceEvent(TraceEventType.Critical, 0);
        }
Ejemplo n.º 21
0
        public void Close()
        {
            var trace = new TraceSource("T1", SourceLevels.All);

            trace.Listeners.Clear();

            var listener = new TestTraceListener();

            trace.Listeners.Add(listener);
            trace.Close();
            // NOTE: this assertion fails on .net 4.5
            // where TraceSource.Close calls TraceListener.Close, not Dispose.
            Assert.Equal(1, listener.GetCallCount(Method.Dispose));
            // Assert that writing to a closed TraceSource is not an error.
            trace.TraceEvent(TraceEventType.Critical, 0);
        }
Ejemplo n.º 22
0
 public void WriteIf1Test()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.WriteIf(false, (Object)"Message");
     Assert.Equal(0, listener.GetCallCount(Method.Write));
     Trace.WriteIf(true, (Object)"Message");
     Assert.Equal(1, listener.GetCallCount(Method.Write));
 }
Ejemplo n.º 23
0
 public void Assert1Test()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.Assert(true);
     Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
     Assert.Equal(0, listener.GetCallCount(Method.Fail));
     Trace.Assert(false);
     Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
     Assert.Equal(1, listener.GetCallCount(Method.Fail));
 }
Ejemplo n.º 24
0
 public void FailTest()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.Fail("Text");
     Assert.Equal(1, listener.GetCallCount(Method.Fail));
     Trace.Fail("Text", "Detail");
     Assert.Equal(2, listener.GetCallCount(Method.Fail));
 }
Ejemplo n.º 25
0
 public void WriteLineIf4Test()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.WriteLineIf(false, "Message", "Category");
     Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
     Trace.WriteLineIf(true, "Message", "Category");
     Assert.Equal(1, listener.GetCallCount(Method.WriteLine));
 }
Ejemplo n.º 26
0
 public void CloseTest()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.Close();
     Assert.Equal(1, listener.GetCallCount(Method.Dispose));
 }
Ejemplo n.º 27
0
 public void SwitchLevelTest(SourceLevels sourceLevel, TraceEventType messageLevel, int expected)
 {
     var trace = new TraceSource("TestTraceSource");
     var listener = new TestTraceListener();
     trace.Listeners.Add(listener);
     trace.Switch.Level = sourceLevel;
     trace.TraceEvent(messageLevel, 0);
     Assert.Equal(expected, listener.GetCallCount(Method.TraceEvent));
 }
Ejemplo n.º 28
0
        public void WriteLineObjectTest()
        {
            var listener = new TestTraceListener();
            listener.Filter = new TestTraceFilter(false);
            listener.WriteLine((Object)"Message");
            Assert.Equal(0, listener.GetCallCount(Method.WriteLine));

            listener.Filter = new TestTraceFilter(true);

            // NOTE: Writing null will result in a newline being written
            listener.WriteLine((Object)null);
            Assert.Equal(1, listener.GetCallCount(Method.WriteLine));

            listener.WriteLine((Object)"Message");
            Assert.Equal(2, listener.GetCallCount(Method.WriteLine));
        }
Ejemplo n.º 29
0
        public void WriteCategoryTest()
        {
            var listener = new TestTraceListener();
            listener.Filter = new TestTraceFilter(false);
            listener.Write("Message", "Category");
            Assert.Equal(0, listener.GetCallCount(Method.Write));

            listener.Filter = new TestTraceFilter(true);

            listener.Write("Message", null);
            Assert.Equal(1, listener.GetCallCount(Method.Write));

            listener.Write("Message", "Category");
            Assert.Equal(2, listener.GetCallCount(Method.Write));

            listener.Write(null, "Category");
            Assert.Equal(3, listener.GetCallCount(Method.Write));
        }
Ejemplo n.º 30
0
 public void Assert3Test()
 {
     var listener = new TestTraceListener();
     var text = new TestTextTraceListener();
     Trace.Listeners.Add(listener);
     Trace.Listeners.Add(text);
     Trace.Assert(true, "Message", "Detail");
     Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
     Assert.Equal(0, listener.GetCallCount(Method.Fail));
     text.Flush();
     Assert.DoesNotContain("Message", text.Output);
     Trace.Assert(false, "Message", "Detail");
     Assert.Equal(0, listener.GetCallCount(Method.WriteLine));
     Assert.Equal(1, listener.GetCallCount(Method.Fail));
     text.Flush();
     Assert.Contains("Message", text.Output);
     Assert.Contains("Detail", text.Output);
 }