예제 #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);
        }