public void QueueHangfire_Logging_LogLevels(LogLevel logLevel) { var hangFireLogger = new HangfireLogProvider(TestLoggerFactory); var sourceContext = "QueueHangfireUnitTests"; var logger = hangFireLogger.GetLogger(sourceContext); var testString = "Test: QueueHangfire_Logging"; logger.Log(logLevel, () => testString); }
public void QueueHangfire_Logging_LogLevels_Bogus() { var hangFireLogger = new HangfireLogProvider(TestLoggerFactory); var sourceContext = "QueueHangfireUnitTests"; var logger = hangFireLogger.GetLogger(sourceContext); Func <bool> fx = () => logger.Log((LogLevel)100, TestString); fx.Should().Throw <ArgumentOutOfRangeException>(); }
public void QueueHangfire_Logging() { var hangFireLogger = new HangfireLogProvider(TestLoggerFactory); var sourceContext = "QueueHangfireUnitTests"; var logger = hangFireLogger.GetLogger(sourceContext); var testString = "Test: QueueHangfire_Logging"; using (TestCorrelator.CreateContext()) { logger.Log(LogLevel.Debug, () => testString); TestCorrelator.GetLogEventsFromCurrentContext() .Should().ContainSingle() .Which.Properties["State"].ToString() .Should().Be(testString.ToDoubleQuoted()); TestCorrelator.GetLogEventsFromCurrentContext() .Should().ContainSingle() .Which.Properties["SourceContext"].ToString() .Should().Be(sourceContext.ToDoubleQuoted()); } }