public void ValidateValueShouldReturnExpectedResultForNonNullValue()
        {
            // arrange
            IPropertyValidator validator = new PropertyValidator<ISite, bool>( s => s.DesignMode, "DesignMode" );
            var errorMessage = "The DesignMode field of type System.Boolean cannot be validated with a null value.";
            object value = null;

            // act
            var actual = validator.ValidateValue( value );

            // assert
            Assert.Equal( 1, actual.Count );
            Assert.Equal( errorMessage, actual[0].ErrorMessage );
            Assert.Equal( "DesignMode", actual[0].MemberNames.Single() );
        }
Ejemplo n.º 2
0
 protected virtual bool IsValid(string path)
 {
     return(PropertyValidator.ValidateValue(path, EditorParams.PropertyInfo, out var none) == ValidationResult.Ok);
 }
        public void ValidateValueShouldReturnExpectedResultForIncompatibleValue()
        {
            // arrange
            IPropertyValidator validator = new PropertyValidator<IComponent, ISite>( c => c.Site, "Site" );
            var errorMessage = "The Site field of type System.ComponentModel.ISite is incompatible with a value of type System.Object.";
            var value = new object();

            // act
            var actual = validator.ValidateValue( value );

            // assert
            Assert.Equal( 1, actual.Count );
            Assert.Equal( errorMessage, actual[0].ErrorMessage );
            Assert.Equal( "Site", actual[0].MemberNames.Single() );
        }