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); }
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))); }
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)); }