File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
2- using Bogus . Tests . Models ;
32using FluentAssertions ;
43using Xunit ;
54
@@ -97,13 +96,20 @@ public void cannot_use_rules_with_strictmode_inside_rulesets()
9796 }
9897
9998 [ Fact ]
100- public void StrictMode_True_NoRules ( )
99+ public void strictmode_with_no_rules_should_throw ( )
101100 {
102- Assert . Throws < ValidationException > ( ( ) =>
103- {
104- new Faker < Order > ( )
105- . StrictMode ( true ) . Generate ( 1 ) ;
106- } ) ;
101+ var faker = new Faker < Examples . Order > ( )
102+ . StrictMode ( true ) ;
103+
104+ Action act = ( ) => faker . Generate ( 1 ) ;
105+
106+ act . Should ( ) . ThrowExactly < ValidationException > ( )
107+ . WithMessage ( "*Missing Rules*" )
108+ . WithMessage ( "*Validation was called to ensure all properties*" )
109+ . WithMessage ( $ "*{ nameof ( Examples . Order . OrderId ) } *")
110+ . WithMessage ( $ "*{ nameof ( Examples . Order . Item ) } *")
111+ . WithMessage ( $ "*{ nameof ( Examples . Order . Quantity ) } *")
112+ . WithMessage ( $ "*{ nameof ( Examples . Order . LotNumber ) } *") ;
107113 }
108114 }
109115}
Original file line number Diff line number Diff line change @@ -744,7 +744,7 @@ private ValidationResult ValidateInternal(string[] ruleSets)
744744 {
745745 foreach ( var propOrFieldOfT in userSet )
746746 {
747- if ( populateActions != null && populateActions . TryGetValue ( propOrFieldOfT , out var populateAction ) )
747+ if ( populateActions is not null && populateActions . TryGetValue ( propOrFieldOfT , out var populateAction ) )
748748 {
749749 // Very much a .Rules() action
750750 if ( populateAction . ProhibitInStrictMode )
You can’t perform that action at this time.
0 commit comments