File tree Expand file tree Collapse file tree 4 files changed +12
-32
lines changed
CodingFlow.FluentValidation.VogenExtensions.UnitTests
CodingFlow.FluentValidation.VogenExtensions Expand file tree Collapse file tree 4 files changed +12
-32
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- using FluentAssertions ;
1+ using CodingFlow . FluentValidation . Validators ;
2+ using FluentAssertions ;
23using static CodingFlow . FluentValidation . Validations ;
34
45namespace CodingFlow . FluentValidation . VogenExtensions . UnitTests ;
@@ -9,21 +10,22 @@ public class VogenValidationsTests
910 public void Between_Float_Valid < T > ( T input )
1011 {
1112 var result = RuleFor ( input )
12- . Valid ( )
13+ . Must ( _ => true )
1314 . VogenResult ( ) ;
1415
1516 result . Should ( ) . BeEquivalentTo ( Vogen . Validation . Ok ) ;
1617 }
1718
19+ private const string ErrorMessage = "Test error." ;
20+
1821 [ TestCase ( 4f ) ]
1922 [ TestCase ( "test string" ) ]
2023 public void Between_Float_Invalid < T > ( T input )
2124 {
2225 var result = RuleFor ( input )
23- . Invalid ( )
26+ . Must ( _ => false ) . WithMessage ( ErrorMessage )
2427 . VogenResult ( ) ;
2528
26- result . Should ( ) . BeEquivalentTo (
27- Vogen . Validation . Invalid ( TestValidations . ErrorMessage ) ) ;
29+ result . Should ( ) . BeEquivalentTo ( Vogen . Validation . Invalid ( ErrorMessage ) ) ;
2830 }
2931}
Original file line number Diff line number Diff line change 4141 </ItemGroup >
4242
4343 <ItemGroup >
44- <PackageReference Include =" CodingFlow.FluentValidation" Version =" 0.2.2 " />
44+ <PackageReference Include =" CodingFlow.FluentValidation" Version =" 0.3.1 " />
4545 <PackageReference Include =" Vogen" Version =" 8.0.4" />
4646 </ItemGroup >
4747
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace CodingFlow.FluentValidation.VogenExtensions;
55public static class VogenValidations
66{
77 /// <summary>
8- /// Creates the validation results for the validation chain and returns it
8+ /// Creates the validation results for the validation chain and returns
99 /// Vogen pass or fail types.
1010 /// </summary>
1111 /// <typeparam name="R">Input type.</typeparam>
@@ -14,10 +14,10 @@ public static class VogenValidations
1414 /// validation fails a <see cref="Validation.Invalid(string)"/>.</returns>
1515 public static Validation VogenResult < R > ( this FluentValidation < R > validation )
1616 {
17- validation . Result = validation . Result ( ) ;
17+ var result = validation . Result ( ) ;
1818
19- return validation . Result . IsValid
19+ return result . IsValid
2020 ? Validation . Ok
21- : Validation . Invalid ( validation . Result . Errors . First ( ) . Message ) ;
21+ : Validation . Invalid ( result . Errors . First ( ) . Message ) ;
2222 }
2323}
You can’t perform that action at this time.
0 commit comments