public void ValidationPassesWhenArrayLengthIsWithinBoundaries(ICollection <string> array) { var attribute = new StringArrayLengthAttribute("Field", 3, 1); var isValid = attribute.IsValid(array); Assert.True(isValid); }
public void IfMinLengthIsNegativeItIsSetToZero() { var minLength = -3; var attribute = new StringArrayLengthAttribute("Field", 4, minLength); Assert.Equal(0, attribute.MinLength); }
public void ValidationFailsWhenArrayLengthIsNotBetweenOneAndThree(ICollection <string> array) { var attribute = new StringArrayLengthAttribute("Field", 3, 1); var isValid = attribute.IsValid(array); Assert.False(isValid); }
public void IfMaxLengthIsGreaterThanMinLengthBothFieldsAreSetToTheSameValue() { var minLength = 3; var maxLength = 1; var attribute = new StringArrayLengthAttribute("Field", maxLength, minLength); Assert.Equal(attribute.MaxLength, minLength); }
public void ValidationFailsWhenMinLengthIsNotSetAndArrayIsNull() { List <string> array = null; var attribute = new StringArrayLengthAttribute("Field", 3); var isValid = attribute.IsValid(array); Assert.False(isValid); }
public void ValidationPassesWhenMinLengthIsNotSetAndArrayIsEmpty() { var array = new List <string>(); var attribute = new StringArrayLengthAttribute("Field", 3); var isValid = attribute.IsValid(array); Assert.True(isValid); }