public void Trace_FiltersOnOwnLevel()
        {
            _traceWriter.Level = TraceLevel.Warning;

            _mockTraceWriter.Setup(p => p.Trace(It.Is <TraceEvent>(q => q.Level == TraceLevel.Warning && q.Source == "TestSource" && q.Message == "Test Warning" && q.Exception == null)));
            _mockTextWriter.Setup(p => p.WriteLine("Test Warning"));

            _traceWriter.Info("Test Information", source: "TestSource"); // don't expect this to be logged
            _traceWriter.Warning("Test Warning", source: "TestSource");

            _mockTextWriter.VerifyAll();
            _mockTraceWriter.VerifyAll();
        }
Beispiel #2
0
        public void Trace_DelegatesToInnerTraceWriterAndTextWriter()
        {
            _mockTraceWriter.Setup(p => p.Trace(It.Is <TraceEvent>(q => q.Level == TraceLevel.Warning && q.Source == "TestSource" && q.Message == "Test Warning" && q.Exception == null)));
            _mockTraceWriter.Setup(p => p.Trace(It.Is <TraceEvent>(q => q.Level == TraceLevel.Error && q.Source == "TestSource" && q.Message == "Test Error" && q.Exception == null)));
            Exception ex = new Exception("Kaboom!");

            _mockTraceWriter.Setup(p => p.Trace(It.Is <TraceEvent>(q => q.Level == TraceLevel.Error && q.Source == "TestSource" && q.Message == "Test Error With Exception" && q.Exception == ex)));

            _mockTextWriter.Setup(p => p.WriteLine("Test Information"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Warning"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Error"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Error With Exception"));
            _mockTextWriter.Setup(p => p.WriteLine(ex.ToDetails()));

            _traceWriter.Info("Test Information", source: "TestSource");  // don't expect this to be logged
            _traceWriter.Warning("Test Warning", source: "TestSource");
            _traceWriter.Error("Test Error", source: "TestSource");
            _traceWriter.Error("Test Error With Exception", ex, source: "TestSource");

            _mockTextWriter.VerifyAll();
            _mockTraceWriter.VerifyAll();
        }
Beispiel #3
0
        public void Trace_DelegatesToInnerTraceWriterAndTextWriter()
        {
            _mockTraceWriter.Setup(p => p.Trace(TraceLevel.Warning, "TestSource", "Test Warning", null));
            _mockTraceWriter.Setup(p => p.Trace(TraceLevel.Error, "TestSource", "Test Error", null));
            Exception ex = new Exception("Kaboom!");

            _mockTraceWriter.Setup(p => p.Trace(TraceLevel.Error, "TestSource", "Test Error With Exception", ex));

            _mockTextWriter.Setup(p => p.WriteLine("Test Information"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Warning"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Error"));
            _mockTextWriter.Setup(p => p.WriteLine("Test Error With Exception"));
            _mockTextWriter.Setup(p => p.WriteLine(ex.ToDetails()));

            _traceWriter.Info("Test Information", source: "TestSource");  // don't expect this to be logged
            _traceWriter.Warning("Test Warning", source: "TestSource");
            _traceWriter.Error("Test Error", source: "TestSource");
            _traceWriter.Error("Test Error With Exception", ex, source: "TestSource");

            _mockTextWriter.VerifyAll();
            _mockTraceWriter.VerifyAll();
        }