diff --git a/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs b/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs index 9ee3efbe309a59..3694d4da397a7a 100644 --- a/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs +++ b/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/HostFactoryResolverTests.cs @@ -271,9 +271,12 @@ public void ApplicationNameSetFromArgument() { Assembly assembly = Assembly.Load("ApplicationNameSetFromArgument"); var factory = HostFactoryResolver.ResolveServiceProviderFactory(assembly, s_WaitTimeout); + Assert.NotNull(factory); IServiceProvider? serviceProvider = factory(Array.Empty()); + Assert.NotNull(serviceProvider); - var configuration = (IConfiguration)serviceProvider.GetService(typeof(IConfiguration)); + var configuration = (IConfiguration?)serviceProvider.GetService(typeof(IConfiguration)); + Assert.NotNull(configuration); Assert.Equal("ApplicationNameSetFromArgument", configuration["applicationName"]); } @@ -284,7 +287,7 @@ public void NoSpecialEntryPointPatternCanRunInParallel() var factory = HostFactoryResolver.ResolveServiceProviderFactory(typeof(NoSpecialEntryPointPattern.Program).Assembly, s_WaitTimeout); Assert.NotNull(factory); - var tasks = new Task[30]; + var tasks = new Task[30]; int index = 0; for (int i = 0; i < tasks.Length; i++) { diff --git a/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/Microsoft.Extensions.HostFactoryResolver.Tests.csproj b/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/Microsoft.Extensions.HostFactoryResolver.Tests.csproj index d24d1061440392..adc356d86a80f5 100644 --- a/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/Microsoft.Extensions.HostFactoryResolver.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/Microsoft.Extensions.HostFactoryResolver.Tests.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) + enable