示例#1
0
文件: Item.cs 项目: Webalap/W-ALAP
 public virtual void ApplyDiscount(Discount discount)
 {
     // Apply the discount
     PriceEachOverride = discount.Apply(this);
     // Add the discount to this product's list.
     Discounts.Add(discount);
 }
示例#2
0
        public void WhenWeBuy5ProductMustReturn3Products()
        {
            const Discount.DiscountType discountType = (Discount.DiscountType) 1;
            var discount = new Discount(discountType, 10, 40); // 40% off from 10 products

            const decimal quantity = 10;
            var           actual   = discount.Apply(quantity, discount);

            Assert.Equal(6, actual);
        }
示例#3
0
        public void WhenWeHaveDiscountTypeQuantityAndReturnIsHalfQuantity()
        {
            const Discount.DiscountType discountType = (Discount.DiscountType) 1;
            var discount = new Discount(discountType, 1000, 10);

            const decimal quantity = 1000;
            var           actual   = discount.Apply(quantity, discount);

            Assert.Equal(900, actual);
        }