public virtual void ApplyDiscount(Discount discount) { // Apply the discount PriceEachOverride = discount.Apply(this); // Add the discount to this product's list. Discounts.Add(discount); }
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); }
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); }