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); }
public void EqualMinTest() { // arrange string value = "15"; // act var attr = new MinLengthAttribute(2); SingleReport result = attr.Validate(value); // assert Assert.AreEqual(true, result.IsValid); }
public void NullTest() { // arrange object value = null; // act var attr = new MinLengthAttribute(2); SingleReport result = attr.Validate(value); // assert Assert.AreEqual(true, result.IsValid); }
public void Validate_ICollection_NetCore_Valid(MinLengthAttribute attribute, object value) { attribute.Validate(value, new ValidationContext(new object())); Assert.True(attribute.IsValid(value)); }
public void Validate_ICollection_NetFx_ThrowsInvalidCastException(MinLengthAttribute attribute, object value) { Assert.Throws <InvalidCastException>(() => attribute.Validate(value, new ValidationContext(new object()))); Assert.Throws <InvalidCastException>(() => attribute.IsValid(value)); }
public void Validate_ICollection_NetCore_Invalid(MinLengthAttribute attribute, object value) { Assert.Throws <ValidationException>(() => attribute.Validate(value, new ValidationContext(new object()))); Assert.False(attribute.IsValid(value)); }