示例#1
0
        public void TestDebugLogging()
        {
            var logger = new DiscreteMemoryLogger("test");

            logger.Debug("test log");
            logger.Debug("test log with param {0}", 1000);
            logger.Debug(new Exception("test exception"), "test log");
            logger.Debug(new Exception("test exception"), "test log with params {0}", 9999);
            CheckLoggerContainsExpectedMessages(logger, LogLevel.Debug);
        }
示例#2
0
        public void TestFailsWhenConstraintIsBreached()
        {
            var logger = new DiscreteMemoryLogger("test");

            logger.Info("hello");
            logger.Debug("hello");

            Assert.That(logger.LogMessages[LogLevel.Debug], Has.Count.GreaterThan(0));
            Assert.That(logger.LogMessages[LogLevel.Information], Has.Count.GreaterThan(0));

            Assert.Throws <AssertionException>(() => Assert.That(logger, HasNotLogged.Above(LogLevel.Debug)));
        }
示例#3
0
        public void TestPassesWhenConstraintShouldMatch()
        {
            var logger = new DiscreteMemoryLogger("test");

            logger.Info("hello");
            logger.Debug("hello");

            Assert.That(logger.LogMessages[LogLevel.Debug], Has.Count.GreaterThan(0));
            Assert.That(logger.LogMessages[LogLevel.Information], Has.Count.GreaterThan(0));

            Assert.That(logger, HasNotLogged.Above(LogLevel.Information));
        }