@@ -34,14 +34,14 @@ public ITestOutputHelper Output
3434 [ SkipOnHelix ( "https://github.com/dotnet/aspnetcore/issues/47478" , Queues = HelixConstants . NativeAotNotSupportedHelixQueues ) ]
3535 public async Task WebApiNativeAotTemplateCSharp ( )
3636 {
37- await WebApiNativeAotTemplateCore ( languageOverride : null ) ;
37+ await WebApiNativeAotTemplateCore ( languageOverride : null , additionalEndpointsThatShould200Ok : new [ ] { "/openapi/v1.json" } ) ;
3838 }
3939
4040 [ ConditionalFact ]
4141 [ SkipOnHelix ( "https://github.com/dotnet/aspnetcore/issues/47478" , Queues = HelixConstants . NativeAotNotSupportedHelixQueues ) ]
4242 public async Task WebApiNativeAotTemplateProgramMainCSharp ( )
4343 {
44- await WebApiNativeAotTemplateCore ( languageOverride : null , args : new [ ] { ArgConstants . UseProgramMain } ) ;
44+ await WebApiNativeAotTemplateCore ( languageOverride : null , args : new [ ] { ArgConstants . UseProgramMain } , additionalEndpointsThatShould200Ok : new [ ] { "/openapi/v1.json" } ) ;
4545 }
4646
4747 [ ConditionalTheory ]
@@ -50,25 +50,14 @@ public async Task WebApiNativeAotTemplateProgramMainCSharp()
5050 [ SkipOnHelix ( "https://github.com/dotnet/aspnetcore/issues/47478" , Queues = HelixConstants . NativeAotNotSupportedHelixQueues ) ]
5151 public async Task WebApiTemplateCSharp_WithoutOpenAPI ( bool useProgramMain )
5252 {
53- var project = await FactoryFixture . CreateProject ( Output ) ;
54-
5553 var args = useProgramMain
5654 ? new [ ] { ArgConstants . UseProgramMain , ArgConstants . NoOpenApi }
5755 : new [ ] { ArgConstants . NoOpenApi } ;
5856
59- await project . RunDotNetNewAsync ( "webapi" , args : args ) ;
60-
61- await project . RunDotNetBuildAsync ( ) ;
62-
63- using var aspNetProcess = project . StartBuiltProjectAsync ( ) ;
64- Assert . False (
65- aspNetProcess . Process . HasExited ,
66- ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built project" , project , aspNetProcess . Process ) ) ;
67-
68- await aspNetProcess . AssertNotFound ( "openapi/v1.json" ) ;
57+ await WebApiNativeAotTemplateCore ( languageOverride : null , args : args , additionalEndpointsThatShould404NotFound : new [ ] { "/openapi/v1.json" } ) ;
6958 }
7059
71- private async Task WebApiNativeAotTemplateCore ( string languageOverride , string [ ] args = null )
60+ private async Task WebApiNativeAotTemplateCore ( string languageOverride , string [ ] args = null , string [ ] additionalEndpointsThatShould200Ok = null , string [ ] additionalEndpointsThatShould404NotFound = null )
7261 {
7362 var project = await ProjectFactory . CreateProject ( Output ) ;
7463 project . SetCurrentRuntimeIdentifier ( ) ;
@@ -101,7 +90,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[]
10190 Assert . False (
10291 aspNetProcess . Process . HasExited ,
10392 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built project" , project , aspNetProcess . Process ) ) ;
104- await AssertEndpoints ( aspNetProcess ) ;
93+ await AssertEndpoints ( aspNetProcess , additionalEndpointsThatShould200Ok , additionalEndpointsThatShould404NotFound ) ;
10594 }
10695
10796 using ( var aspNetProcess = project . StartPublishedProjectAsync ( noHttps : true , usePublishedAppHost : true ) )
@@ -110,15 +99,31 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[]
11099 aspNetProcess . Process . HasExited ,
111100 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run published project" , project , aspNetProcess . Process ) ) ;
112101
113- await AssertEndpoints ( aspNetProcess ) ;
102+ await AssertEndpoints ( aspNetProcess , additionalEndpointsThatShould200Ok , additionalEndpointsThatShould404NotFound ) ;
114103 }
115104 }
116105
117- private async Task AssertEndpoints ( AspNetProcess aspNetProcess )
106+ private async Task AssertEndpoints ( AspNetProcess aspNetProcess , string [ ] additionalEndpointsThatShould200Ok = null , string [ ] additionalEndpointsThatShould404NotFound = null )
118107 {
119108 await aspNetProcess . AssertOk ( "/todos" ) ;
120109 await aspNetProcess . AssertOk ( "/todos/1" ) ;
121110 await aspNetProcess . AssertNotFound ( "/todos/100" ) ;
122111 await aspNetProcess . AssertNotFound ( "/" ) ;
112+
113+ if ( additionalEndpointsThatShould200Ok is not null )
114+ {
115+ foreach ( var endpoint in additionalEndpointsThatShould200Ok )
116+ {
117+ await aspNetProcess . AssertOk ( endpoint ) ;
118+ }
119+ }
120+
121+ if ( additionalEndpointsThatShould404NotFound is not null )
122+ {
123+ foreach ( var endpoint in additionalEndpointsThatShould404NotFound )
124+ {
125+ await aspNetProcess . AssertNotFound ( endpoint ) ;
126+ }
127+ }
123128 }
124129}
0 commit comments