diff --git a/Directory.Build.props b/Directory.Build.props index 1d3faf8d8..3cc66064c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -51,7 +51,7 @@ - + ).MakeGenericType(virtualizeJsInteropType); - var dotNetObjectReferenceValuePropertyInfo = dotNetObjectReferenceVirtualizeJsInteropType - .GetProperty("Value", BindingFlags.Public | BindingFlags.Instance) + var dotNetObjectReferenceValuePropertyInfo = dotNetObjectReferenceVirtualizeJsInteropType.GetProperty("Value", BindingFlags.Public | BindingFlags.Instance) ?? throw new InvalidOperationException("Did not find the Value property on the DotNetObjectReference type."); - var onSpacerBeforeVisibleMethodInfo = virtualizeJsInteropType?.GetMethod("OnSpacerBeforeVisible") + var onSpacerBeforeVisibleMethodInfo = virtualizeJsInteropType.GetMethod("OnSpacerBeforeVisible") ?? throw new InvalidOperationException("Did not find the OnSpacerBeforeVisible method on the VirtualizeJsInterop type."); return (dotNetObjectReferenceValuePropertyInfo, onSpacerBeforeVisibleMethodInfo); diff --git a/tests/bunit.web.testcomponents.tests/RazorTesting/RazorTestSourceInformationProviderTest.cs b/tests/bunit.web.testcomponents.tests/RazorTesting/RazorTestSourceInformationProviderTest.cs index 0ac75a963..d92d09932 100644 --- a/tests/bunit.web.testcomponents.tests/RazorTesting/RazorTestSourceInformationProviderTest.cs +++ b/tests/bunit.web.testcomponents.tests/RazorTesting/RazorTestSourceInformationProviderTest.cs @@ -32,8 +32,8 @@ public void Test001(Type target, int testNumber, int expectedLineNumber) var sourceInfo = sut.GetSourceInformation(target, GetTest(target, testNumber), testNumber); sourceInfo.ShouldNotBeNull(); - sourceInfo?.FileName.ShouldEndWith($"SampleComponents{Path.DirectorySeparatorChar}{target.Name}.razor", Case.Insensitive); - sourceInfo?.LineNumber.ShouldBe(expectedLineNumber); + sourceInfo.FileName.ShouldEndWith($"SampleComponents{Path.DirectorySeparatorChar}{target.Name}.razor", Case.Insensitive); + sourceInfo.LineNumber.ShouldBe(expectedLineNumber); } public void Dispose() => renderer.Dispose(); diff --git a/tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj b/tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj index 089372ed7..510e3d3ce 100644 --- a/tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj +++ b/tests/bunit.web.testcomponents.tests/bunit.web.testcomponents.tests.csproj @@ -15,7 +15,6 @@ NU1605 - diff --git a/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthenticationStateProviderTest.cs b/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthenticationStateProviderTest.cs index 821164d8c..f96ed2e7a 100644 --- a/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthenticationStateProviderTest.cs +++ b/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthenticationStateProviderTest.cs @@ -15,8 +15,8 @@ public async Task Test001() // assert Assert.NotNull(authState.User); Assert.NotNull(authState.User.Identity); - Assert.Equal("TestUser", authState?.User?.Identity?.Name); - Assert.True(authState?.User?.Identity?.IsAuthenticated); + Assert.Equal("TestUser", authState.User?.Identity?.Name); + Assert.True(authState.User?.Identity?.IsAuthenticated); } [Fact(DisplayName = "Create unauthenticated AuthenticationState")] diff --git a/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs b/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs index 08c0ec4d6..25897b285 100644 --- a/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs +++ b/tests/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs @@ -45,10 +45,10 @@ public async Task Test003() // assert Assert.NotNull(policy); - Assert.Equal(1, policy?.AuthenticationSchemes?.Count); - Assert.Equal("TestScheme:FooBar", policy?.AuthenticationSchemes?[0]); - Assert.Equal(1, policy?.Requirements?.Count); - Assert.IsType(policy?.Requirements?[0]); + Assert.Equal(1, policy.AuthenticationSchemes?.Count); + Assert.Equal("TestScheme:FooBar", policy.AuthenticationSchemes?[0]); + Assert.Equal(1, policy.Requirements?.Count); + Assert.IsType(policy.Requirements?[0]); } [Fact(DisplayName = "Get policy based on name not in the PolicyProvider.")] @@ -63,10 +63,10 @@ public async Task Test004() // assert Assert.NotNull(policy); - Assert.Equal(1, policy?.AuthenticationSchemes?.Count); - Assert.Equal("TestScheme:OtherPolicy", policy?.AuthenticationSchemes?[0]); - Assert.Equal(1, policy?.Requirements?.Count); - Assert.IsType(policy?.Requirements?[0]); + Assert.Equal(1, policy.AuthenticationSchemes?.Count); + Assert.Equal("TestScheme:OtherPolicy", policy.AuthenticationSchemes?[0]); + Assert.Equal(1, policy.Requirements?.Count); + Assert.IsType(policy.Requirements?[0]); } [Fact(DisplayName = "Set Policies with empty scheme name.")]