public TestServerFixture() { var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Testing"; var x = WebTestHelpers.GetWebApplicationPath(); var builder = new WebHostBuilder() .UseEnvironment(environment) .UseContentRoot(WebTestHelpers.GetWebApplicationPath()) .UseConfiguration(Configuration) .UseStartup <TestStartup>(); _testServer = new TestServer(builder); Client = _testServer.CreateClient(); Client.BaseAddress = new Uri("http://localhost:5000"); }
public TestServerFixture() { var environment = "Testing"; var applicationPath = WebTestHelpers.GetWebApplicationPath(); _testServer = new TestServer(new WebHostBuilder() .UseEnvironment(environment) .UseContentRoot(applicationPath) .ConfigureServices(x => { x.AddAntiforgery(t => { t.Cookie.Name = AntiForgeryCookieName; t.FormFieldName = AntiForgeryFieldName; }); }) .UseConfiguration(new ConfigurationBuilder() .SetBasePath(applicationPath) .AddJsonFile($"appsettings.{environment}.json") .Build()) .UseStartup <Startup>()); Client = _testServer.CreateClient(); }