Ejemplo n.º 1
0
        public void EvaluateShouldReturnSuccessForNullValue()
        {
            // arrange
            var rule = new StringLengthRule( 10 );
            var property = new Property<string>( "Text", null );
            var expected = ValidationResult.Success;

            // act
            var actual = rule.Evaluate( property );

            // assert
            Assert.Equal( expected, actual );
        }
Ejemplo n.º 2
0
        public void EvaluateWithMinLengthShouldReturnExpectedResultForInvalidValue( int count )
        {
            // arrange
            var value = new string( 'x', count );
            var rule = new StringLengthRule( 1, 10 );
            var property = new Property<string>( "Text", value );

            // act
            var actual = rule.Evaluate( property );

            // assert
            Assert.Equal( "The Text field must be a string with a minimum length of 1 and a maximum length of 10.", actual.ErrorMessage );
            Assert.Equal( 1, actual.MemberNames.Count() );
            Assert.Equal( "Text", actual.MemberNames.Single() );
        }