private IntegrationTestEnvironment(EnvironmentSetupOptions options = null) { this.cancellationTokenSource = new CancellationTokenSource(); options ??= new EnvironmentSetupOptions(); EnvironmentHelper.SetRunningInTestFlag(); this.host = Host.CreateDefaultBuilder() .ConfigureAppConfiguration(ConfigureConfigurationBuilder) .UseEnvironment(options.EnvironmentName ?? Environments.Development) .ConfigureWebHostDefaults(webBuilder => webBuilder .UseStartup <Startup>() .UseKestrel() .UseUrls("https://*:14569;http://*:14568") .UseNGrok(new NgrokOptions() { ShowNGrokWindow = false, Disable = false, ApplicationHttpUrl = "http://localhost:14568" })) .ConfigureServices(services => { TestServiceProviderFactory.ConfigureServicesForTesting(services); options.IocConfiguration?.Invoke(services); }) .Build(); serviceScope = this.host.Services.CreateScope(); ServiceProvider = serviceScope.ServiceProvider; this.options = options; }
public static async Task <IntegrationTestEnvironment> CreateAsync(EnvironmentSetupOptions options = null) { var environment = new IntegrationTestEnvironment(options); await environment.InitializeWebServer(); return(environment); }