Esempio n. 1
0
        public void ShouldSetLoggingLevelOnNewObjects()
        {
            var mock1 = new MockListener();

            Tracer.SetLoggingLevel("System.Diagnostics", SourceLevels.Information);

            var source = Tracer.GetSourceFor<Foo>();

            Tracer.AddListener("System.Diagnostics", mock1);

            source.TraceInformation("foo");
            source.Flush();

            Assert.IsTrue(mock1.Invoked);
        }
Esempio n. 2
0
        public void ShouldInvokeAddedListeners()
        {
            var mock1 = new MockListener();
            var mock2 = new MockListener();

            Tracer.AddListener("System.Diagnostics", mock1);
            Tracer.AddListener("System.Diagnostics", mock2);

            var source = Tracer.GetSourceFor<Foo>();

            source.Sources.ForEach(ts => ts.Switch.Level = SourceLevels.Information);

            source.TraceInformation("foo");
            source.Flush();

            Assert.IsTrue(mock1.Invoked);
            Assert.IsTrue(mock2.Invoked);
        }