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 ;
23using FluentAssertions ;
34using Xunit ;
45
@@ -94,5 +95,15 @@ public void cannot_use_rules_with_strictmode_inside_rulesets()
9495 Action act2 = ( ) => faker2 . AssertConfigurationIsValid ( ) ;
9596 act2 . Should ( ) . Throw < ValidationException > ( ) ;
9697 }
98+
99+ [ Fact ]
100+ public void StrictMode_True_NoRules ( )
101+ {
102+ Assert . Throws < ValidationException > ( ( ) =>
103+ {
104+ new Faker < Order > ( )
105+ . StrictMode ( true ) . Generate ( 1 ) ;
106+ } ) ;
107+ }
97108 }
98109}
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 . TryGetValue ( propOrFieldOfT , out var populateAction ) )
747+ if ( populateActions != 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