public void LogMessage() { // Arrange var controller = "home"; var action = "index"; var testSink = new TestSink(); var testLogger = new TestLogger("testlogger", testSink, enabled: true); // Act testLogger.ActionMatched(controller, action); // Assert Assert.Equal(1, testSink.Writes.Count); var writeContext = testSink.Writes.First(); var actualLogValues = Assert.IsAssignableFrom <IReadOnlyList <KeyValuePair <string, object> > >(writeContext.State); AssertLogValues( new[] { new KeyValuePair <string, object>("{OriginalFormat}", TestLoggerExtensions.ActionMatchedInfo.NamedStringFormat), new KeyValuePair <string, object>("controller", controller), new KeyValuePair <string, object>("action", action) }, actualLogValues.ToArray()); Assert.Equal(LogLevel.Information, writeContext.LogLevel); Assert.Equal(1, writeContext.EventId); Assert.Null(writeContext.Exception); Assert.Equal( string.Format( TestLoggerExtensions.ActionMatchedInfo.FormatString, controller, action), actualLogValues.ToString()); }