Example #1
0
        public void Cannot_calculate_coupon_discount_for_empty_cart_products_list()
        {
            //setup
            var couponDiscount = new CouponDiscount(threshold: 100, discount: 5);

            Assert.Throws <ApplicationException>(() =>
                                                 couponDiscount.Calculate(cartProducts: null, cartSubtotal: 100));
            Assert.Throws <ApplicationException>(() =>
                                                 couponDiscount.Calculate(cartProducts: new List <CartProduct>(), cartSubtotal: 100));
        }
Example #2
0
        public void CouponCalculateTestThrows(double price,
                                              double value)
        {
            var discount = new CouponDiscount(value);

            Assert.That(() => discount.Calculate(price), Throws.TypeOf <ArgumentException>());
        }
Example #3
0
        public void Cannot_calculate_coupon_discount_for_invalid_cart_subTotal()
        {
            //setup
            var couponDiscount = new CouponDiscount(threshold: 100, discount: 5);
            var cartProduct    = new CartProduct(new Product(code: "9501101530002", name: "Cheerios", price: 6.99m));

            Assert.Throws <ApplicationException>(() =>
                                                 couponDiscount.Calculate(cartProducts: new List <CartProduct>()
            {
                cartProduct
            }, cartSubtotal: 0));
            Assert.Throws <ApplicationException>(() =>
                                                 couponDiscount.Calculate(cartProducts: new List <CartProduct>()
            {
                cartProduct
            }, cartSubtotal: -100));
        }
Example #4
0
        public void CouponCalculateTest(double price, double value, double result)
        {
            var discount = new CouponDiscount(value);

            Assert.That(() => discount.Calculate(price), Is.EqualTo(result));
        }