Example #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"));
        }
Example #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));
        }
Example #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"));
        }
Example #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);
        }