public void EvaluateShouldReturnSuccessForNullValue() { // arrange var rule = new SizeRule<IEnumerable<int>>( 1 ); var property = new Property<IEnumerable<int>>( "Points", null ); var expected = ValidationResult.Success; // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual ); }
public void EvaluateShouldReturnExpectedResultForInvalidValue( int count ) { // arrange var value = Enumerable.Range( 1, count ); var rule = new SizeRule<IEnumerable<int>>( 1, 10 ); var property = new Property<IEnumerable<int>>( "Points", value ); // act var actual = rule.Evaluate( property ); // assert Assert.Equal( "The Points field must be a sequence with a minimum count of 1 and a maximum count of 10.", actual.ErrorMessage ); Assert.Equal( 1, actual.MemberNames.Count() ); Assert.Equal( "Points", actual.MemberNames.Single() ); }