public async Task GetPrivacy_Through_Normal_Startup() { var builder = new WebHostBuilder().UseStartup <Startup>(); var client = new TestServer(builder).CreateClient(); var result = await client.GetAsync("/Home/Privacy"); result.StatusCode.Should().Be(HttpStatusCode.OK); }
public async Task GetPrivacy_Through_Test_Startup_In_Test_Project() { var builder = new WebHostBuilder().ConfigureServices(services => { var startupAssembly = typeof(TestStartupInTestProject).GetTypeInfo().Assembly; var manager = new ApplicationPartManager(); manager.ApplicationParts.Add(new AssemblyPart(startupAssembly)); manager.ApplicationParts.Add(new AssemblyPart(typeof(HomeController).Assembly)); manager.FeatureProviders.Add(new ControllerFeatureProvider()); manager.FeatureProviders.Add(new ViewComponentFeatureProvider()); services.AddSingleton(manager); }).UseStartup <TestStartupInTestProject>(); var client = new TestServer(builder).CreateClient(); var result = await client.GetAsync("/Home/Privacy"); result.StatusCode.Should().Be(HttpStatusCode.OK); }