public void Launch() { var builder = new WebHostBuilder(); builder.UseContentRoot(GetContentRootPath()) .UseEnvironment(_environment) .ConfigureLogging(factory => { factory.AddConsole(); }) .UseAutofacMultitenant((context, options) => { options.ValidateOnBuild = false; options.MapDefaultTenantToAllRootDomains(); options.AddTenantsFromConfig(context.Configuration); options.ConfigureTenants(builder => { builder.MapToTenantIdSubDomain(); }); }) .UseConfiguration(_configBuilder.Invoke(_environment, builder.GetSetting(WebHostDefaults.ContentRootKey))) .UseStartup <T>() .ConfigureServices(services => { services.AddAntiforgery(options => { options.Cookie.Name = AntiForgeryCookieName; options.FormFieldName = AntiForgeryFieldName; }); //Test Server Fix //https://github.com/aspnet/Hosting/issues/954 //https://github.com/Microsoft/vstest/issues/428 var assembly = typeof(T).GetTypeInfo().Assembly; services.ConfigureRazorViewEngineForTestServer(assembly, _netVersion); }); _testServer = new Microsoft.AspNetCore.TestHost.TestServer(builder); Client = _testServer.CreateClient(); }