Exemplo n.º 1
0
        public void DefaultLoggerWithoutVerboseOutputWritesDebugLevelMessages()
        {
            //given
            DefaultLogger log = new DefaultLogger(false);

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

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

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

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

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

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

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

            // then
            Assert.That(logOutputLines, Is.Empty);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 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);
        }