@@ -76,17 +76,13 @@ public void GenerateSitemapXml_DoesNotIncludeIdentityRoutes()
7676        var  baseUrl  =  "https://test.example.com/" ; 
7777
7878        // Act & Assert 
79-         var  nodes  =  _Factory . InServiceScope ( serviceProvider => 
80-         { 
81-             var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
82-             SitemapXmlHelpers . GenerateSitemapXml ( 
83-                 tempDir , 
84-                 siteMappings , 
85-                 routeConfigurationService , 
86-                 baseUrl , 
87-                 out  var  nodes ) ; 
88-             return  nodes ; 
89-         } ) ; 
79+         var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
80+         SitemapXmlHelpers . GenerateSitemapXml ( 
81+             tempDir , 
82+             siteMappings , 
83+             routeConfigurationService , 
84+             baseUrl , 
85+             out  var  nodes ) ; 
9086
9187        var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
9288
@@ -108,17 +104,13 @@ public void GenerateSitemapXml_IncludesBaseUrl()
108104        var  baseUrl  =  "https://test.example.com/" ; 
109105
110106        // Act & Assert 
111-         var  nodes  =  _Factory . InServiceScope ( serviceProvider => 
112-         { 
113-             var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
114-             SitemapXmlHelpers . GenerateSitemapXml ( 
115-                 tempDir , 
116-                 siteMappings , 
117-                 routeConfigurationService , 
118-                 baseUrl , 
119-                 out  var  nodes ) ; 
120-             return  nodes ; 
121-         } ) ; 
107+         var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
108+         SitemapXmlHelpers . GenerateSitemapXml ( 
109+             tempDir , 
110+             siteMappings , 
111+             routeConfigurationService , 
112+             baseUrl , 
113+             out  var  nodes ) ; 
122114
123115        Assert . Contains ( nodes ,  node =>  node . Url  ==  baseUrl ) ; 
124116
@@ -143,22 +135,19 @@ public void GenerateSitemapXml_IncludesSiteMappingsMarkedForXml()
143135        } ; 
144136
145137        // Act & Assert 
146-         _Factory . InServiceScope ( serviceProvider => 
147-         { 
148-             var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
149-             SitemapXmlHelpers . GenerateSitemapXml ( 
150-                 tempDir , 
151-                 siteMappings , 
152-                 routeConfigurationService , 
153-                 baseUrl , 
154-                 out  var  nodes ) ; 
138+         var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
139+         SitemapXmlHelpers . GenerateSitemapXml ( 
140+             tempDir , 
141+             siteMappings , 
142+             routeConfigurationService , 
143+             baseUrl , 
144+             out  var  nodes ) ; 
155145
156-              var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
146+         var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
157147
158-             Assert . Contains ( allUrls ,  url =>  url . Contains ( "test-page-1" ) ) ; 
159-             Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "test-page-2" ) ) ;  // Not marked for XML 
160-             Assert . Contains ( allUrls ,  url =>  url . Contains ( "test-page-3" ) ) ; 
161-         } ) ; 
148+         Assert . Contains ( allUrls ,  url =>  url . Contains ( "test-page-1" ) ) ; 
149+         Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "test-page-2" ) ) ;  // Not marked for XML 
150+         Assert . Contains ( allUrls ,  url =>  url . Contains ( "test-page-3" ) ) ; 
162151    } 
163152
164153    [ Fact ] 
@@ -170,21 +159,18 @@ public void GenerateSitemapXml_DoesNotIncludeIndexRoutes()
170159        var  baseUrl  =  "https://test.example.com/" ; 
171160
172161        // Act & Assert 
173-         _Factory . InServiceScope ( serviceProvider => 
174-         { 
175-             var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
176-             SitemapXmlHelpers . GenerateSitemapXml ( 
177-                 tempDir , 
178-                 siteMappings , 
179-                 routeConfigurationService , 
180-                 baseUrl , 
181-                 out  var  nodes ) ; 
162+         var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
163+         SitemapXmlHelpers . GenerateSitemapXml ( 
164+             tempDir , 
165+             siteMappings , 
166+             routeConfigurationService , 
167+             baseUrl , 
168+             out  var  nodes ) ; 
182169
183-              var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
170+         var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
184171
185-             // Should not include Index action routes (they're the default) 
186-             Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "/Index" ,  StringComparison . OrdinalIgnoreCase ) ) ; 
187-         } ) ; 
172+         // Should not include Index action routes (they're the default) 
173+         Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "/Index" ,  StringComparison . OrdinalIgnoreCase ) ) ; 
188174    } 
189175
190176    [ Fact ] 
@@ -196,21 +182,18 @@ public void GenerateSitemapXml_DoesNotIncludeErrorRoutes()
196182        var  baseUrl  =  "https://test.example.com/" ; 
197183
198184        // Act & Assert 
199-         _Factory . InServiceScope ( serviceProvider => 
200-         { 
201-             var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
202-             SitemapXmlHelpers . GenerateSitemapXml ( 
203-                 tempDir , 
204-                 siteMappings , 
205-                 routeConfigurationService , 
206-                 baseUrl , 
207-                 out  var  nodes ) ; 
185+         var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
186+         SitemapXmlHelpers . GenerateSitemapXml ( 
187+             tempDir , 
188+             siteMappings , 
189+             routeConfigurationService , 
190+             baseUrl , 
191+             out  var  nodes ) ; 
208192
209-              var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
193+         var  allUrls  =  nodes . Select ( n =>  n . Url ) . ToList ( ) ; 
210194
211-             // Should not include Error action routes 
212-             Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "/Error" ,  StringComparison . OrdinalIgnoreCase ) ) ; 
213-         } ) ; 
195+         // Should not include Error action routes 
196+         Assert . DoesNotContain ( allUrls ,  url =>  url . Contains ( "/Error" ,  StringComparison . OrdinalIgnoreCase ) ) ; 
214197    } 
215198
216199    [ Fact ] 
@@ -224,24 +207,18 @@ public void GenerateAndSerializeSitemapXml_CreatesFileSuccessfully()
224207
225208        // Clean up any existing file 
226209        var  expectedXmlPath  =  Path . Combine ( tempDir . FullName ,  "sitemap.xml" ) ; 
227-         if  ( File . Exists ( expectedXmlPath ) ) 
228-         { 
229-             File . Delete ( expectedXmlPath ) ; 
230-         } 
210+         File . Delete ( expectedXmlPath ) ; 
231211
232212        try 
233213        { 
234214            // Act 
235-             _Factory . InServiceScope ( serviceProvider => 
236-             { 
237-                 var  routeConfigurationService  =  serviceProvider . GetRequiredService < IRouteConfigurationService > ( ) ; 
238-                 SitemapXmlHelpers . GenerateAndSerializeSitemapXml ( 
239-                     tempDir , 
240-                     siteMappings , 
241-                     logger , 
242-                     routeConfigurationService , 
243-                     baseUrl ) ; 
244-             } ) ; 
215+             var  routeConfigurationService  =  _Factory . Services . GetRequiredService < IRouteConfigurationService > ( ) ; 
216+             SitemapXmlHelpers . GenerateAndSerializeSitemapXml ( 
217+                 tempDir , 
218+                 siteMappings , 
219+                 logger , 
220+                 routeConfigurationService , 
221+                 baseUrl ) ; 
245222
246223            // Assert 
247224            Assert . True ( File . Exists ( expectedXmlPath ) ) ; 
@@ -254,10 +231,7 @@ public void GenerateAndSerializeSitemapXml_CreatesFileSuccessfully()
254231        finally 
255232        { 
256233            // Clean up 
257-             if  ( File . Exists ( expectedXmlPath ) ) 
258-             { 
259-                 File . Delete ( expectedXmlPath ) ; 
260-             } 
234+             File . Delete ( expectedXmlPath ) ; 
261235        } 
262236    } 
263237
0 commit comments