コード例 #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);
        }