Exemplo n.º 1
0
        public void TestInfoLogging()
        {
            var logger = new DiscreteMemoryLogger("test");

            logger.Info("test log");
            logger.Info("test log with param {0}", 1000);
            logger.Info(new Exception("test exception"), "test log");
            logger.Info(new Exception("test exception"), "test log with params {0}", 9999);
            CheckLoggerContainsExpectedMessages(logger, LogLevel.Information);
        }
Exemplo n.º 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)));
        }
Exemplo n.º 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));
        }