public void IsValid_GiveProperData_ReturnsTrue() { // arrange List <int> ids = new List <int>() { 1, 2, 3 }; var context = new ValidationContext(ids); var attrib = new CustomIDsValidationAttribute(); // act var result = attrib.IsValid(ids); // assert Assert.That(result, Is.True); }
public void IsValid_GiveIdsWhichAreLessThanZero_ReturnsFalse() { // arrange List <int> ids = new List <int>() { 1, -1, -4 }; var context = new ValidationContext(ids); var attrib = new CustomIDsValidationAttribute(); // act var result = attrib.IsValid(ids); // assert Assert.That(result, Is.False); Assert.That(attrib.ErrorMessage == "ID should not be zero or less."); }
public void IsValid_GiveSameIds_ReturnsFalse() { // arrange List <int> ids = new List <int>() { 1, 2, 2 }; var context = new ValidationContext(ids); var attrib = new CustomIDsValidationAttribute(); // act var result = attrib.IsValid(ids); // assert Assert.That(result, Is.False); Assert.That(attrib.ErrorMessage == " ID values should be distinct."); }