diff --git a/test/test.xunit.runner.visualstudio/TestCaseFilterTests.cs b/test/test.xunit.runner.visualstudio/TestCaseFilterTests.cs index b0c21eb..b7caa5f 100644 --- a/test/test.xunit.runner.visualstudio/TestCaseFilterTests.cs +++ b/test/test.xunit.runner.visualstudio/TestCaseFilterTests.cs @@ -33,7 +33,7 @@ static TestCase GetDummyTestCaseWithTraits() }; } - static LoggerHelper GetLoggerHelper(IMessageLogger messageLogger = null) + static LoggerHelper GetLoggerHelper(IMessageLogger? messageLogger = null) { return new LoggerHelper(messageLogger ?? Substitute.For(), new Stopwatch()); } @@ -46,8 +46,8 @@ public void TestCaseFilter_SingleMatch() var context = Substitute.For(); var filterExpression = Substitute.For(); // The matching should return a single testcase - filterExpression.MatchTestCase(null, null).ReturnsForAnyArgs(x => ((TestCase)x[0]).FullyQualifiedName.Equals(dummyTestCaseDisplayNamefilterString)); - context.GetTestCaseFilter(null, null).ReturnsForAnyArgs(filterExpression); + filterExpression.MatchTestCase(null!, null!).ReturnsForAnyArgs(x => ((TestCase)x[0]).FullyQualifiedName.Equals(dummyTestCaseDisplayNamefilterString)); + context.GetTestCaseFilter(null, null!).ReturnsForAnyArgs(filterExpression); var filter = new TestCaseFilter(context, GetLoggerHelper(), "dummyTestAssembly", dummyKnownTraits); var results = dummyTestCaseList.Where(filter.MatchTestCase); @@ -61,7 +61,7 @@ public void TestCaseFilter_NoFilterString() { var dummyTestCaseList = GetDummyTestCases(); var context = Substitute.For(); - context.GetTestCaseFilter(null, null).ReturnsForAnyArgs((ITestCaseFilterExpression)null); + context.GetTestCaseFilter(null, null!).ReturnsForAnyArgs(default(ITestCaseFilterExpression)); var filter = new TestCaseFilter(context, GetLoggerHelper(), "dummyTestAssembly", dummyKnownTraits); var results = dummyTestCaseList.Where(filter.MatchTestCase); @@ -76,7 +76,7 @@ public void TestCaseFilter_ErrorParsingFilterString() var messageLogger = Substitute.For(); var dummyTestCaseList = GetDummyTestCases(); var context = Substitute.For(); - context.GetTestCaseFilter(null, null).ReturnsForAnyArgs(x => { throw new TestPlatformFormatException("Hello from the exception"); }); + context.GetTestCaseFilter(null, null!).ReturnsForAnyArgs(x => { throw new TestPlatformFormatException("Hello from the exception"); }); var filter = new TestCaseFilter(context, GetLoggerHelper(messageLogger), "dummyTestAssembly", dummyKnownTraits); var results = dummyTestCaseList.Where(filter.MatchTestCase); @@ -86,7 +86,7 @@ public void TestCaseFilter_ErrorParsingFilterString() var args = messageLogger.ReceivedCalls().Single().GetArguments(); Assert.Collection(args, arg => Assert.Equal(TestMessageLevel.Warning, arg), - arg => Assert.EndsWith("dummyTestAssembly: Exception filtering tests: Hello from the exception", (string)arg) + arg => Assert.EndsWith("dummyTestAssembly: Exception filtering tests: Hello from the exception", (string)arg!) ); } diff --git a/test/test.xunit.runner.visualstudio/test.xunit.runner.visualstudio.csproj b/test/test.xunit.runner.visualstudio/test.xunit.runner.visualstudio.csproj index 3230325..15b1164 100644 --- a/test/test.xunit.runner.visualstudio/test.xunit.runner.visualstudio.csproj +++ b/test/test.xunit.runner.visualstudio/test.xunit.runner.visualstudio.csproj @@ -1,6 +1,7 @@ + enable Exe net472;net6.0