Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
}
public class WebApplicationFactoryWithWebHost<TStartup> : Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TStartup>
where TStartup : class
{
public WebApplicationFactoryWithWebHost() { }
public System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> BuilderCustomization { get; set; }
protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Hosting;

namespace ServiceComposer.AspNetCore.Testing
{
public class WebApplicationFactoryWithWebHost<TStartup> :
WebApplicationFactory<TStartup>
where TStartup : class
{
public Action<IWebHostBuilder> BuilderCustomization { get; set; }

protected override IHostBuilder CreateHostBuilder()
{
return Host.CreateDefaultBuilder(Array.Empty<string>())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<TStartup>();
});
}

protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);

BuilderCustomization?.Invoke(builder);
}
}
}