public void EvaluateShouldReturnSuccessForNullValue() { // arrange var rule = new NullableRangeRule<int>( 0 ); var property = new Property<int?>( "Counter", null ); var expected = ValidationResult.Success; // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual ); }
public void EvaluateShouldReturnExpectedResultForInvalidValue( int value ) { // arrange var rule = new NullableRangeRule<int>( 1, 10 ); var property = new Property<int?>( "Counter", value ); // act var actual = rule.Evaluate( property ); // assert Assert.Equal( "The Counter field must be between 1 and 10.", actual.ErrorMessage ); Assert.Equal( 1, actual.MemberNames.Count() ); Assert.Equal( "Counter", actual.MemberNames.Single() ); }