public void CLogger_ExpectedMessages_Message()
        {
            using (var output = new OutputCaptureScope())
            {
                // 1. Logger without timestamps
                var logger = new ConsoleLogger(includeTimestamp: false);

                logger.LogInfo("message1");
                output.AssertExpectedLastMessage("message1");

                logger.LogInfo("message2", null);
                output.AssertExpectedLastMessage("message2");

                logger.LogInfo("message3 {0}", "xxx");
                output.AssertExpectedLastMessage("message3 xxx");

                // 2. Logger with timestamps
                logger = new ConsoleLogger(includeTimestamp: true);

                logger.LogInfo("message4");
                output.AssertLastMessageEndsWith("message4");

                logger.LogInfo("message5{0}{1}", null, null);
                output.AssertLastMessageEndsWith("message5");

                logger.LogInfo("message6 {0}{1}", "xxx", "yyy", "zzz");
                output.AssertLastMessageEndsWith("message6 xxxyyy");
            }
        }
        public void CLogger_Verbosity()
        {
            var logger = new ConsoleLogger(includeTimestamp: false);

            logger.Verbosity.Should().Be(LoggerVerbosity.Debug, "Default verbosity should be Debug");

            using (var output = new OutputCaptureScope())
            {
                logger.Verbosity = LoggerVerbosity.Info;
                logger.LogInfo("info1");
                output.AssertExpectedLastMessage("info1");
                logger.LogInfo("info2");
                output.AssertExpectedLastMessage("info2");
                logger.LogDebug("debug1");
                output.AssertExpectedLastMessage("info2"); // the debug message should not have been logged

                logger.Verbosity = LoggerVerbosity.Debug;
                logger.LogDebug("debug");
                output.AssertExpectedLastMessage("debug");
                logger.LogInfo("info3");
                output.AssertExpectedLastMessage("info3");

                logger.Verbosity = LoggerVerbosity.Info;
                logger.LogInfo("info4");
                output.AssertExpectedLastMessage("info4");
                logger.LogDebug("debug2");
                output.AssertExpectedLastMessage("info4");
            }
        }
        public void CLogger_FormattedStrings()
        {
            using (var output = new OutputCaptureScope())
            {
                // 1. Logger without timestamps
                var logger = new ConsoleLogger(includeTimestamp: false);

                logger.LogInfo("{ }");
                output.AssertExpectedLastMessage("{ }");

                logger.LogInfo("}{");
                output.AssertExpectedLastMessage("}{");

                logger.LogInfo("a{1}2", null);
                output.AssertExpectedLastMessage("a{1}2");

                logger.LogInfo("{0}", "123");
                output.AssertExpectedLastMessage("123");

                logger.LogInfo("a{0}{{{1}}}", "11", "22");
                output.AssertExpectedLastMessage("a11{22}");

                // 2. Logger with timestamps
                logger = new ConsoleLogger(includeTimestamp: true);

                logger.LogInfo("{ }");
                output.AssertLastMessageEndsWith("{ }");

                logger.LogInfo("}{");
                output.AssertLastMessageEndsWith("}{");

                logger.LogInfo("a{1}2", null);
                output.AssertLastMessageEndsWith("a{1}2");

                logger.LogInfo("{0}", "123");
                output.AssertLastMessageEndsWith("123");

                logger.LogInfo("a{0}{{{1}}}", "11", "22");
                output.AssertLastMessageEndsWith("a11{22}");
            }
        }