Exemplo n.º 1
0
        //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));
        }
Exemplo n.º 2
0
        //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);
        }