GetCallCount() public méthode

Gets the number of times any of the public methods on this instance were called.
public GetCallCount ( Method group ) : int
group Method
Résultat int
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
        }
        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));
        }
Exemple #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));
        }
Exemple #12
0
        public void CloseTest()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Close();
            Assert.Equal(1, listener.GetCallCount(Method.Dispose));
        }
Exemple #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));
        }
Exemple #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);
        }
        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));
        }
Exemple #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));
        }
Exemple #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);
        }
 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));
 }
        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);
        }
        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);
        }
Exemple #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);
        }
Exemple #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));
 }
Exemple #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));
 }
Exemple #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));
 }
Exemple #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));
 }
Exemple #26
0
 public void CloseTest()
 {
     var listener = new TestTraceListener();
     Trace.Listeners.Add(listener);
     Trace.Close();
     Assert.Equal(1, listener.GetCallCount(Method.Dispose));
 }
 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));
 }
        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));
        }
        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));
        }
Exemple #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);
 }