diff --git a/Divergic.Logging.Xunit.UnitTests/CacheLoggerTests.cs b/Divergic.Logging.Xunit.UnitTests/CacheLoggerTests.cs index 7716f83..0c1ba0b 100644 --- a/Divergic.Logging.Xunit.UnitTests/CacheLoggerTests.cs +++ b/Divergic.Logging.Xunit.UnitTests/CacheLoggerTests.cs @@ -235,13 +235,13 @@ public void LogCachesLogMessageTest(LogLevel logLevel) [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void LogDoesLogsRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNotNullTest(string data) + public void LogDoesLogsRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNotNullTest(string? data) { const LogLevel logLevel = LogLevel.Error; var eventId = Model.Create(); var state = Guid.NewGuid().ToString(); var exception = new ArgumentNullException(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); - string Formatter(string message, Exception? error) => data; + string Formatter(string message, Exception? error) => data!; var source = Substitute.For(); @@ -282,12 +282,12 @@ public void LogDoesLogsRecordWhenFormatterReturnsMessageAndExceptionIsNull() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void LogDoesNotLogRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNullTest(string data) + public void LogDoesNotLogRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNullTest(string? data) { const LogLevel logLevel = LogLevel.Error; var eventId = Model.Create(); var state = Guid.NewGuid().ToString(); - string Formatter(string message, Exception? error) => data; + string Formatter(string message, Exception? error) => data!; var source = Substitute.For(); diff --git a/Divergic.Logging.Xunit.UnitTests/DefaultFormatterTests.cs b/Divergic.Logging.Xunit.UnitTests/DefaultFormatterTests.cs index d05d21d..11e2c45 100644 --- a/Divergic.Logging.Xunit.UnitTests/DefaultFormatterTests.cs +++ b/Divergic.Logging.Xunit.UnitTests/DefaultFormatterTests.cs @@ -80,7 +80,7 @@ public void FormatHidesSensitiveDataInMessage(string? sensitiveValue, string mes [InlineData("", true)] [InlineData(" ", true)] [InlineData("stuff", true)] - public void FormatIncludesNewLineBetweenMessageAndException(string message, bool exceptionExists) + public void FormatIncludesNewLineBetweenMessageAndException(string? message, bool exceptionExists) { var config = new LoggingConfig(); var scopeLevel = 1; @@ -93,7 +93,7 @@ public void FormatIncludesNewLineBetweenMessageAndException(string message, bool var sut = new DefaultFormatter(config); - var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message, exception); + var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message!, exception); actual.Should().NotStartWith(Environment.NewLine); actual.Should().NotEndWith(Environment.NewLine); @@ -125,7 +125,7 @@ public void FormatIncludesNewLineBetweenMessageAndException(string message, bool [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string message) + public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string? message) { var config = new LoggingConfig().Set(x => x.ScopePaddingSpaces = 2); var scopeLevel = 1; @@ -135,7 +135,7 @@ public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string message) var sut = new DefaultFormatter(config); - var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message, null); + var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message!, null); actual.Should().BeEmpty(); } diff --git a/Divergic.Logging.Xunit.UnitTests/ScopeScenarioTests.cs b/Divergic.Logging.Xunit.UnitTests/ScopeScenarioTests.cs index 0891514..6d30c97 100644 --- a/Divergic.Logging.Xunit.UnitTests/ScopeScenarioTests.cs +++ b/Divergic.Logging.Xunit.UnitTests/ScopeScenarioTests.cs @@ -71,7 +71,7 @@ public void TestOutputWritesMessagesInContextOfScopesWithSensitiveData() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void TestOutputWritesMessagesUsingScopesWithoutState(string scopeState) + public void TestOutputWritesMessagesUsingScopesWithoutState(string? scopeState) { Logger.LogCritical("Writing critical message"); Logger.LogDebug("Writing debug message"); @@ -80,11 +80,11 @@ public void TestOutputWritesMessagesUsingScopesWithoutState(string scopeState) Logger.LogTrace("Writing trace message"); Logger.LogWarning("Writing warning message"); - using (Logger.BeginScope((object) scopeState)) + using (Logger.BeginScope((object) scopeState!)) { Logger.LogInformation("Inside first scope"); - using (Logger.BeginScope((object) scopeState)) + using (Logger.BeginScope((object) scopeState!)) { Logger.LogInformation("Inside second scope"); } @@ -195,7 +195,7 @@ public async Task UsingParallelTasks() return Task.CompletedTask; })).ToList(); - await Task.WhenAll(tasks).ConfigureAwait(false); + await Task.WhenAll(tasks); Task StartOnDefaultScheduler(Func asyncFunc) { diff --git a/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerProviderTests.cs b/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerProviderTests.cs index 353e15e..2ecd3e4 100644 --- a/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerProviderTests.cs +++ b/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerProviderTests.cs @@ -22,14 +22,14 @@ public void CanDisposeMultipleTimes() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void CreateLoggerThrowsExceptionWithInvalidCategoryNameTest(string categoryName) + public void CreateLoggerThrowsExceptionWithInvalidCategoryNameTest(string? categoryName) { var output = Substitute.For(); using var sut = new TestOutputLoggerProvider(output); // ReSharper disable once AccessToDisposedClosure - Action action = () => sut.CreateLogger(categoryName); + Action action = () => sut.CreateLogger(categoryName!); action.Should().Throw(); } diff --git a/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerTests.cs b/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerTests.cs index d37756d..0aab651 100644 --- a/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerTests.cs +++ b/Divergic.Logging.Xunit.UnitTests/TestOutputLoggerTests.cs @@ -79,7 +79,7 @@ public void LogIgnoresTestBoundaryFailure() var task = new Task(async () => { - await Task.Delay(0).ConfigureAwait(false); + await Task.Delay(0); sut.LogCritical("message2"); }); @@ -198,12 +198,12 @@ public void LogWritesMessageUsingSpecifiedLineFormatter() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void ThrowsExceptionWhenCreatedWithInvalidCategoryNameTest(string categoryName) + public void ThrowsExceptionWhenCreatedWithInvalidCategoryNameTest(string? categoryName) { var output = Substitute.For(); // ReSharper disable once ObjectCreationAsStatement - Action action = () => new TestOutputLogger(categoryName, output); + Action action = () => new TestOutputLogger(categoryName!, output); action.Should().Throw(); }