예제 #1
0
        public void WhenReplacingTracer_ThenTracersInvokeIt()
        {
            var tracer = new Mock <ITracer> {
                DefaultValue = DefaultValue.Mock
            };

            using (TracerExtensibility.SetTracer(tracer.Object))
            {
                global::System.Diagnostics.Tracer.GetSourceFor <IComparable>();

                tracer.Verify(x => x.GetSourceEntryFor("*"));
                tracer.Verify(x => x.GetSourceEntryFor("System"));
                tracer.Verify(x => x.GetSourceEntryFor("System.IComparable"));
            }
        }
예제 #2
0
        public void WhenDisposingReplacedTracerResult_ThenRevertsToExisting()
        {
            var tracer = new Mock <ITracer> {
                DefaultValue = DefaultValue.Mock
            };

            using (TracerExtensibility.SetTracer(tracer.Object))
            {
            }

            global::System.Diagnostics.Tracer.GetSourceFor <IComparable>();

            tracer.Verify(x => x.GetSourceEntryFor("*"), Times.Never());
            tracer.Verify(x => x.GetSourceEntryFor("System"), Times.Never());
            tracer.Verify(x => x.GetSourceEntryFor("System.IComparable"), Times.Never());
        }
예제 #3
0
 public void WhenSettingNullTracer_ThenThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           TracerExtensibility.SetTracer(null));
 }