Exemplo n.º 1
0
        private static Errors ValidateProperty(PropertyInfo property, object entity, object value)
        {
            var errors = new Errors();

            RequiredAttribute.Validate(property, value, errors);
            MaxLengthAttribute.Validate(property, value, errors);
            MinLengthAttribute.Validate(property, value, errors);

            return(errors);
        }
Exemplo n.º 2
0
 public void Validate_ICollection_NetCore_Invalid(MaxLengthAttribute attribute, object value)
 {
     Assert.Throws <ValidationException>(() => attribute.Validate(value, new ValidationContext(new object())));
     Assert.False(attribute.IsValid(value));
 }
Exemplo n.º 3
0
 public void Validate_ICollection_NetCore_Valid(MaxLengthAttribute attribute, object value)
 {
     attribute.Validate(value, new ValidationContext(new object()));
     Assert.True(attribute.IsValid(value));
 }
Exemplo n.º 4
0
        public static void GetValidationResult_InvalidLength_ThrowsInvalidOperationException(int length)
        {
            var attribute = new MaxLengthAttribute(length);

            Assert.Throws <InvalidOperationException>(() => attribute.Validate("Twoflower", new ValidationContext(new object())));
        }
Exemplo n.º 5
0
 public void Validate_ICollection_NetFx_ThrowsInvalidCastException(MaxLengthAttribute attribute, object value)
 {
     Assert.Throws <InvalidCastException>(() => attribute.Validate(value, new ValidationContext(new object())));
     Assert.Throws <InvalidCastException>(() => attribute.IsValid(value));
 }