//required and negative condition is valid here since that's the responsibility of Required and RangeAttribute public void InvalidInputShouldThrowException(decimal lowerDiscount, decimal upperDiscount) { var rateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount }; var greaterThanAttribute = new GreaterThanFieldAttribute("LowerDiscount"); var validationContext = new ValidationContext(rateOption); //No exception means succes Assert.Throws <ValidationException>(() => greaterThanAttribute.Validate(upperDiscount, validationContext)); }
public void InvalidInputShouldThrowException(decimal increment, decimal lowerDiscount, decimal upperDiscount) { var rateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount }; var greaterThanAttribute = new LessThanOrEqualToDifferenceOfTwoFieldsAndPositiveAttribute("LowerDiscount", "UpperDiscount"); var validationContext = new ValidationContext(rateOption); Assert.Throws <ValidationException>(() => greaterThanAttribute.Validate(increment, validationContext)); }
//required and negative condition is valid here since that's the responsibility of Required and RangeAttribute public void ValidInputShouldPassValidation(decimal lowerDiscount, decimal upperDiscount) { var rateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount }; var greaterThanAttribute = new GreaterThanFieldAttribute("LowerDiscount"); var validationContext = new ValidationContext(rateOption); //No exception means success greaterThanAttribute.Validate(upperDiscount, validationContext); }
public void ValidInputShouldPassValidation(decimal increment, decimal lowerDiscount, decimal upperDiscount) { var rateOption = new RateOption { LowerDiscount = lowerDiscount, UpperDiscount = upperDiscount }; var greaterThanAttribute = new LessThanOrEqualToDifferenceOfTwoFieldsAndPositiveAttribute("LowerDiscount", "UpperDiscount"); var validationContext = new ValidationContext(rateOption); //No exception means success greaterThanAttribute.Validate(increment, validationContext); }