@@ -25,12 +25,13 @@ public void TestingInfrastructure_WebHost_WithWebHostBuilderRespectsCustomizatio
2525
2626 // Assert
2727 Assert . Equal ( new [ ] { "ConfigureWebHost" , "Customization" , "FurtherCustomization" } , factory . ConfigureWebHostCalled . ToArray ( ) ) ;
28- Assert . True ( factory . CreateServerCalled ) ;
29- Assert . False ( factory . CreateWebHostBuilderCalled ) ;
28+ Assert . True ( factory . CreateServerIWebHostBuilderCalled ) ;
29+ Assert . False ( factory . CreateServerWithServiceProviderCalled ) ;
30+ Assert . True ( factory . CreateWebHostBuilderCalled ) ;
3031 // GetTestAssemblies is not called when reading content roots from MvcAppManifest
3132 Assert . False ( factory . GetTestAssembliesCalled ) ;
3233 Assert . True ( factory . CreateHostBuilderCalled ) ;
33- Assert . True ( factory . CreateHostCalled ) ;
34+ Assert . False ( factory . CreateHostCalled ) ;
3435 }
3536
3637 [ Fact ]
@@ -48,7 +49,8 @@ public void TestingInfrastructure_GenericHost_WithWithHostBuilderRespectsCustomi
4849 Assert . False ( factory . GetTestAssembliesCalled ) ;
4950 Assert . True ( factory . CreateHostBuilderCalled ) ;
5051 Assert . True ( factory . CreateHostCalled ) ;
51- Assert . True ( factory . CreateServerCalled ) ;
52+ Assert . False ( factory . CreateServerIWebHostBuilderCalled ) ;
53+ Assert . True ( factory . CreateServerWithServiceProviderCalled ) ;
5254 Assert . False ( factory . CreateWebHostBuilderCalled ) ;
5355 }
5456
@@ -108,6 +110,23 @@ public void TestingInfrastructure_GenericHost_HostDispose()
108110 Assert . True ( sink . _asyncDisposed ) ;
109111 }
110112
113+ [ Fact ]
114+ public void TestingInfrastructure_WebApplicationBuilder_RespectsCustomizations ( )
115+ {
116+ // Arrange
117+ using var factory = new CustomizedFactory < SimpleWebSiteWithWebApplicationBuilder . Program > ( ) ;
118+ factory . StartServer ( ) ;
119+
120+ // Assert
121+ Assert . Equal ( [ "ConfigureWebHost" ] , factory . ConfigureWebHostCalled . ToArray ( ) ) ;
122+ Assert . False ( factory . GetTestAssembliesCalled ) ;
123+ Assert . True ( factory . CreateHostBuilderCalled ) ;
124+ Assert . True ( factory . CreateHostCalled ) ;
125+ Assert . False ( factory . CreateServerIWebHostBuilderCalled ) ;
126+ Assert . True ( factory . CreateServerWithServiceProviderCalled ) ;
127+ Assert . True ( factory . CreateWebHostBuilderCalled ) ;
128+ }
129+
111130 private static void ConfigureWebHostBuilder ( IWebHostBuilder builder ) =>
112131 builder . UseStartup < GenericHostWebSite . Startup > ( )
113132 . ConfigureServices ( s => s . AddScoped < DisposableService > ( ) ) ;
@@ -131,7 +150,8 @@ private class CustomizedFactory<TEntryPoint> : WebApplicationFactory<TEntryPoint
131150 public bool GetTestAssembliesCalled { get ; private set ; }
132151 public bool CreateWebHostBuilderCalled { get ; private set ; }
133152 public bool CreateHostBuilderCalled { get ; private set ; }
134- public bool CreateServerCalled { get ; private set ; }
153+ public bool CreateServerIWebHostBuilderCalled { get ; private set ; }
154+ public bool CreateServerWithServiceProviderCalled { get ; private set ; }
135155 public bool CreateHostCalled { get ; private set ; }
136156 public IList < string > ConfigureWebHostCalled { get ; private set ; } = new List < string > ( ) ;
137157
@@ -143,13 +163,13 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
143163
144164 protected override TestServer CreateServer ( IWebHostBuilder builder )
145165 {
146- CreateServerCalled = true ;
166+ CreateServerIWebHostBuilderCalled = true ;
147167 return base . CreateServer ( builder ) ;
148168 }
149169
150170 protected override TestServer CreateServer ( IServiceProvider serviceProvider )
151171 {
152- CreateServerCalled = true ;
172+ CreateServerWithServiceProviderCalled = true ;
153173 return base . CreateServer ( serviceProvider ) ;
154174 }
155175
0 commit comments