コード例 #1
0
        public void Error_InvalidFormatStringInException_DoesNotThrow()
        {
            var sink = new FakeLoggingSink();

            new DefaultLogger(sink).Error(new Exception("{abc"), "test");

            Assert.That(sink.LastEntry.Message, Does.Contain("{abc"));
        }
コード例 #2
0
        public void Error_WhenCalled_LogLevelIsError()
        {
            var sink = new FakeLoggingSink();

            DefaultLogger.LogLevel = LogLevel.Debug;
            new DefaultLogger(sink).Error("some message");

            Assert.That(sink.LastEntry.Level, Is.EqualTo(LogLevel.Error));
        }
コード例 #3
0
        public void Write_LogLevelGreaterThanConfigured_MessageWritten()
        {
            var sink   = new FakeLoggingSink();
            var logger = new DefaultLogger(sink);

            DefaultLogger.LogLevel = LogLevel.Info;
            logger.Write(LogLevel.Warning, "some message");

            Assert.That(sink.LastEntry.Message, Is.EqualTo("some message"));
        }
コード例 #4
0
        public void Write_LogLevelLessThanConfigured_NoMessageWritten()
        {
            var sink   = new FakeLoggingSink();
            var logger = new DefaultLogger(sink);

            DefaultLogger.LogLevel = LogLevel.Warning;
            logger.Write(LogLevel.Info, "some message");

            Assert.That(sink.LastEntry, Is.Null);
        }