Commit 2514029 1 parent b4198ce commit 2514029 Copy full SHA for 2514029
File tree 1 file changed +43
-0
lines changed
test/Danom.Validation.Tests
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ namespace Danom . Validation . Tests ;
2
+
3
+ using Xunit ;
4
+ using FluentValidation ;
5
+ using Danom . TestHelpers ;
6
+
7
+ public sealed class ValidationOptionTests
8
+ {
9
+ [ Fact ]
10
+ public void ReturnsSomeOption_WhenValidationSucceeds ( )
11
+ {
12
+ var input = new TestInput { Value = 1 } ;
13
+ var result = ValidationOption < TestInput > . From < TestInputValidator > ( input ) ;
14
+
15
+ AssertOption . IsNone ( result ) ;
16
+ Assert . False ( result . IsSome ) ;
17
+ }
18
+
19
+ [ Fact ]
20
+ public void ReturnsNoneOption_WhenValidationFails ( )
21
+ {
22
+ var input = new TestInput { Value = 0 } ;
23
+ var result = ValidationOption < TestInput > . From < TestInputValidator > ( input ) ;
24
+
25
+ AssertOption . IsNone ( result ) ;
26
+ Assert . False ( result . IsSome ) ;
27
+ }
28
+
29
+ public sealed class TestInput
30
+ {
31
+ public int Value { get ; set ; }
32
+
33
+ public override string ToString ( ) => Value . ToString ( ) ;
34
+ }
35
+
36
+ public sealed class TestInputValidator : AbstractValidator < TestInput >
37
+ {
38
+ public TestInputValidator ( )
39
+ {
40
+ RuleFor ( x => x . Value ) . GreaterThan ( 0 ) ;
41
+ }
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments