public void IsValidCompareDifferentTypes() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator(10); Assert.IsTrue(notEqualToValidator.IsValid(10M)); Assert.IsTrue(notEqualToValidator.IsValid("10")); }
public void IsValidCompareIntegerValue() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator(10); Assert.IsFalse(notEqualToValidator.IsValid(10)); Assert.IsTrue(notEqualToValidator.IsValid(1)); }
public void IsValidCompareStringWithOrdinalIgnoreCaseComparer() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator("TEST", StringComparer.OrdinalIgnoreCase); Assert.IsFalse(notEqualToValidator.IsValid("test")); Assert.IsFalse(notEqualToValidator.IsValid("TEST")); }
public void IsValidCompareString() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator("TEST"); Assert.IsTrue(notEqualToValidator.IsValid("test")); Assert.IsTrue(notEqualToValidator.IsValid("Test")); Assert.IsFalse(notEqualToValidator.IsValid("TEST")); }
public void GetValidator() { const string valueToCompare = "TEST"; IEqualityComparer comparer = StringComparer.OrdinalIgnoreCase; NotEqualToValidationAttribute notEqualToValidationAttribute = new NotEqualToValidationAttribute(valueToCompare, comparer); Assert.IsInstanceOf(typeof(NotEqualToValidator), notEqualToValidationAttribute.GetValidator()); NotEqualToValidator notEqualToValidator = (NotEqualToValidator)notEqualToValidationAttribute.GetValidator(); Assert.AreEqual(valueToCompare, notEqualToValidator.ValueToCompare); Assert.AreEqual(comparer, notEqualToValidator.Comparer); }
public void IsValidCompareNullValue() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator(string.Empty); Assert.IsTrue(notEqualToValidator.IsValid(null)); }
public void IsValidCompareEmptyString() { NotEqualToValidator notEqualToValidator = new NotEqualToValidator(string.Empty); Assert.IsFalse(notEqualToValidator.IsValid(string.Empty)); }