File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
ServiceComposer.AspNetCore.Testing.Tests
ServiceComposer.AspNetCore.Testing Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1717 protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
1818 protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
1919 }
20+ public class WebApplicationFactoryWithWebHost<TStartup> : Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TStartup>
21+ where TStartup : class
22+ {
23+ public WebApplicationFactoryWithWebHost() { }
24+ public System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> BuilderCustomization { get; set; }
25+ protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { }
26+ protected override Microsoft.Extensions.Hosting.IHostBuilder CreateHostBuilder() { }
27+ }
2028}
Original file line number Diff line number Diff line change 1+ using System ;
2+ using Microsoft . AspNetCore . Hosting ;
3+ using Microsoft . AspNetCore . Mvc . Testing ;
4+ using Microsoft . Extensions . Hosting ;
5+
6+ namespace ServiceComposer . AspNetCore . Testing
7+ {
8+ public class WebApplicationFactoryWithWebHost < TStartup > :
9+ WebApplicationFactory < TStartup >
10+ where TStartup : class
11+ {
12+ public Action < IWebHostBuilder > BuilderCustomization { get ; set ; }
13+
14+ protected override IHostBuilder CreateHostBuilder ( )
15+ {
16+ return Host . CreateDefaultBuilder ( Array . Empty < string > ( ) )
17+ . ConfigureWebHostDefaults ( webBuilder =>
18+ {
19+ webBuilder . UseStartup < TStartup > ( ) ;
20+ } ) ;
21+ }
22+
23+ protected override void ConfigureWebHost ( IWebHostBuilder builder )
24+ {
25+ base . ConfigureWebHost ( builder ) ;
26+
27+ BuilderCustomization ? . Invoke ( builder ) ;
28+ }
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments