File tree Expand file tree Collapse file tree
CommonTestUtilities/Requests
Validators.Test/User/Register Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace CommonTestUtilities.Requests;
55
66public static class RegisterUserRequestJSONMockFactory
77{
8- public static RegisterUserRequestJSON CreateMock ( )
8+ public static RegisterUserRequestJSON CreateMock ( int length = 10 )
99 => new Faker < RegisterUserRequestJSON > ( )
1010 . CustomInstantiator ( f =>
1111 {
@@ -14,7 +14,7 @@ public static RegisterUserRequestJSON CreateMock()
1414 return new RegisterUserRequestJSON (
1515 name ,
1616 f . Internet . Email ( name ) ,
17- f . Internet . Password ( )
17+ f . Internet . Password ( length )
1818 ) ;
1919 } ) . Generate ( ) ;
2020
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ public void Test_OnFailureWith_EmptyEmail()
4242 result . Errors . Should ( ) . ContainSingle ( )
4343 . And . Contain ( e => e . ErrorMessage . Equals ( ResourcesAccessor . EMAIL_REQUIRED ) ) ;
4444 }
45-
4645 [ Fact ]
4746 public void Test_OnFailureWith_InvalidEmail ( )
4847 {
@@ -64,4 +63,19 @@ public void Test_OnFailureWith_EmptyPassword()
6463 result . Errors . Should ( ) . ContainSingle ( )
6564 . And . Contain ( e => e . ErrorMessage . Equals ( ResourcesAccessor . PASSWORD_REQUIRED ) ) ;
6665 }
66+ [ Theory ]
67+ [ InlineData ( 1 ) ]
68+ [ InlineData ( 2 ) ]
69+ [ InlineData ( 3 ) ]
70+ [ InlineData ( 4 ) ]
71+ [ InlineData ( 5 ) ]
72+ public void Test_OnFailureWith_InvalidPassword ( int passwordLength )
73+ {
74+ var request = RegisterUserRequestJSONMockFactory . CreateMock ( passwordLength ) ;
75+ var result = _validator . Validate ( request ) ;
76+
77+ result . IsValid . Should ( ) . BeFalse ( ) ;
78+ result . Errors . Should ( ) . ContainSingle ( )
79+ . And . Contain ( e => e . ErrorMessage . Equals ( ResourcesAccessor . PASSWORD_LENGTH ) ) ;
80+ }
6781}
You can’t perform that action at this time.
0 commit comments