public void DefaultLoggerWithoutVerboseOutputWritesDebugLevelMessages()
        {
            //given
            DefaultLogger log = new DefaultLogger(false);

            //then
            Assert.That(log.IsDebugEnabled, Is.False);
        }
        public void DefaultLoggerWithVerboseOutputWritesInfoLevelMessages()
        {
            //given
            DefaultLogger log = new DefaultLogger(true);

            //then
            Assert.That(log.IsInfoEnabled, Is.True);
        }
示例#3
0
        public void InfoDoesNotLogIfLogLevelInfoIsDisabled()
        {
            //given
            var target = new DefaultLogger(LogLevel.WARN, writeLineAction);

            // when
            target.Info("Info message");

            // then
            Assert.That(logOutputLines, Is.Empty);
        }
示例#4
0
        public void InfoDoesNotLogIfLogLevelDebugIsDisabled()
        {
            //given
            var target = new DefaultLogger(LogLevel.INFO, writeLineAction);

            // when
            target.Debug("Debug message");

            // then
            Assert.That(logOutputLines, Is.Empty);
        }
        public void DebugDoesNotLogIfVerboseIsDisabled()
        {
            //given
            var target = new DefaultLogger(false, writeLineAction);

            // when
            target.Debug("Debug message");

            // then
            Assert.That(logOutputLines, Is.Empty);
        }
示例#6
0
        public void InfoLogsAppropriateMessage()
        {
            //given
            var target = new DefaultLogger(LogLevel.DEBUG, writeLineAction);

            // when
            target.Info("Info message");

            // then
            Assert.That(logOutputLines.Count, Is.EqualTo(1));
            Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} INFO  \\[.+?\\] Info message$"), Is.True);
        }
        public void WarningLogsAppropriateMessage()
        {
            //given
            var target = new DefaultLogger(true, writeLineAction);

            // when
            target.Warn("Warning message");

            // then
            Assert.That(logOutputLines.Count, Is.EqualTo(1));
            Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} WARN  \\[.+?\\] Warning message$"), Is.True);
        }
示例#8
0
        public void ErrorWithStacktraceLogsAppropriateMessage()
        {
            //given
            var exception = new Exception("test exception");
            var target    = new DefaultLogger(LogLevel.DEBUG, writeLineAction);

            // when
            target.Error("Error message", exception);

            // then
            Assert.That(logOutputLines.Count, Is.EqualTo(1));
            Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} ERROR \\[.+?\\] Error message(\n|\r|\r\n){Regex.Escape(exception.ToString())}$",
                                      RegexOptions.Singleline), Is.True);
        }