Skip to content

Commit

Permalink
Enable nullable in test project
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 30, 2024
1 parent 68deb29 commit e2d5be2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/test.xunit.runner.visualstudio/TestCaseFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMessageLogger>(), new Stopwatch());
}
Expand All @@ -46,8 +46,8 @@ public void TestCaseFilter_SingleMatch()
var context = Substitute.For<IRunContext>();
var filterExpression = Substitute.For<ITestCaseFilterExpression>();
// 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);
Expand All @@ -61,7 +61,7 @@ public void TestCaseFilter_NoFilterString()
{
var dummyTestCaseList = GetDummyTestCases();
var context = Substitute.For<IRunContext>();
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);
Expand All @@ -76,7 +76,7 @@ public void TestCaseFilter_ErrorParsingFilterString()
var messageLogger = Substitute.For<IMessageLogger>();
var dummyTestCaseList = GetDummyTestCases();
var context = Substitute.For<IRunContext>();
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);
Expand All @@ -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!)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
</PropertyGroup>
Expand Down

0 comments on commit e2d5be2

Please sign in to comment.