File tree Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -221,21 +221,15 @@ public void IgnoreSection(string sectionName)
221
221
throw new ArgumentNullException ( nameof ( sectionName ) ) ;
222
222
}
223
223
224
- if ( ! PreviousSectionWriters . ContainsKey ( sectionName ) )
224
+ if ( PreviousSectionWriters . ContainsKey ( sectionName ) )
225
225
{
226
- // If the section is not defined, throw an error.
227
- throw new InvalidOperationException ( Resources . FormatSectionNotDefined (
228
- ViewContext . ExecutingFilePath ,
229
- sectionName ,
230
- ViewContext . View . Path ) ) ;
231
- }
226
+ if ( _ignoredSections == null )
227
+ {
228
+ _ignoredSections = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
229
+ }
232
230
233
- if ( _ignoredSections == null )
234
- {
235
- _ignoredSections = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
231
+ _ignoredSections . Add ( sectionName ) ;
236
232
}
237
-
238
- _ignoredSections . Add ( sectionName ) ;
239
233
}
240
234
241
235
/// <inheritdoc />
Original file line number Diff line number Diff line change @@ -480,7 +480,7 @@ public async Task RenderSection_ThrowsIfRequiredSectionIsNotFound()
480
480
}
481
481
482
482
[ Fact ]
483
- public async Task IgnoreSection_ThrowsIfSectionIsNotFound ( )
483
+ public async Task IgnoreSection_DoesNotThrowIfSectionIsNotFound ( )
484
484
{
485
485
// Arrange
486
486
var context = CreateViewContext ( viewPath : "/Views/TestPath/Test.cshtml" ) ;
@@ -496,10 +496,8 @@ public async Task IgnoreSection_ThrowsIfSectionIsNotFound()
496
496
} ;
497
497
498
498
// Act & Assert
499
- var ex = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) => page . ExecuteAsync ( ) ) ;
500
- var message = $ "The layout page '/Views/Shared/_Layout.cshtml' cannot find the section 'bar'" +
501
- " in the content page '/Views/TestPath/Test.cshtml'." ;
502
- Assert . Equal ( message , ex . Message ) ;
499
+ await page . ExecuteAsync ( ) ;
500
+ // Nothing to assert, just getting here is validation enough.
503
501
}
504
502
505
503
[ Fact ]
You can’t perform that action at this time.
0 commit comments