Exemple #1
0
        public void debug_does_not_log_if_logger_level_is_lower()
        {
            const string msg    = "This is the message";
            var          logger = new InMemoryLogger(LogLevel.Info);

            logger.Logs.Count.ShouldBe(0);

            logger.Debug(msg);

            logger.Logs.Count.ShouldBe(0);
        }
Exemple #2
0
        public void debug_logs_string_to_buffer()
        {
            const string msg    = "This is the message";
            var          logger = new InMemoryLogger();

            logger.Logs.Count.ShouldBe(0);

            logger.Debug(msg);

            var entry = logger.Logs[0];

            entry.ShouldNotBeNull();
            entry.Exception.ShouldBeNull();
            entry.Level.ShouldBe(LogLevel.Debug);
            entry.Message.Equals(msg).ShouldBeTrue();
        }
Exemple #3
0
        public void debug_logs_object_to_buffer()
        {
            ValueType obj    = true;
            var       logger = new InMemoryLogger();

            logger.Logs.Count.ShouldBe(0);

            logger.Debug(obj);

            var entry = logger.Logs[0];

            entry.ShouldNotBeNull();
            entry.Exception.ShouldBeNull();
            entry.Level.ShouldBe(LogLevel.Debug);
            entry.Message.Equals("True").ShouldBeTrue();
        }
Exemple #4
0
        public void LoggedMessagesAreStoredAndAccessible()
        {
            const string debug = "Debug Message";
            const string trace = "Trace Message";
            const string fatal = "Fatal Message";

            var logger = new InMemoryLogger();

            logger.Logs.Count.ShouldBe(0);

            logger.Debug(debug);
            logger.Trace(trace);
            logger.Fatal(fatal);

            logger.Logs.Count.ShouldBe(3);

            var logs = logger.LogMessages;

            logs[0].ShouldBe(debug);
            logs[1].ShouldBe(trace);
            logs[2].ShouldBe(fatal);
        }