public void PriceForQuantity_OnUnderBundleSize_ShouldReturnActualPricing() { var decorator = new BundleDiscount(_testItem, 3, 200); var expectedPriceInCents = 2 * 75; // 2 apple at 0.75 actual price Assert.AreEqual(expectedPriceInCents, decorator.GetEffectivePrice(2)); }
public void TestCouponProductIdWithBundle() { var product1 = GetContactProduct(); var product2 = GetApplicantProduct(); var coupon1 = CreateCoupon(1, false, CreatePercentageDiscount(), null, new[] { product1.Id }); AssertException.Thrown <CouponProductException>(() => _ordersCommand.ValidateCoupon(coupon1, null, null)); _ordersCommand.ValidateCoupon(coupon1, null, new[] { product1.Id }); // Purchase. var ownerId = Guid.NewGuid(); var creditCard = CreateCreditCard(CreditCardType.Visa); var discount = new BundleDiscount { Percentage = BundleDiscount }; var order = _ordersCommand.PrepareOrder(new[] { product1.Id, product2.Id }, coupon1, new[] { discount }, creditCard.CardType); var receipt = _ordersCommand.PurchaseOrder(ownerId, order, new Purchaser { Id = ownerId }, creditCard) as CreditCardReceipt; // Assert. AssertAllocations(ownerId, order.Id, product1.CreditAdjustments.Concat(product2.CreditAdjustments).ToArray()); AssertOrders(ownerId, coupon1, discount, product1, product2); AssertReceipt(order.Id, receipt); AssertException.Thrown <CouponProductException>(() => _ordersCommand.ValidateCoupon(coupon1, null, null)); _ordersCommand.ValidateCoupon(coupon1, null, new[] { product1.Id }); }
public void PriceForQuantity_OnEligibleBundleSize_ShouldReturnBundleDiscountPricing() { var decorator = new BundleDiscount(_testItem, 3, 200); var expectedPriceInCents = 200 + 75; //3 apples at 2.00 + 1 at 0.75 Assert.AreEqual(expectedPriceInCents, decorator.GetEffectivePrice(4)); }
private IList <Discount> GetDiscounts(IEnumerable <Guid> productIds, Discount discount) { // If both products are being bought then a discount is applied. if (productIds == null || productIds.Count() < 2) { return discount == null ? null : new[] { discount } } ; var bundleDiscount = new BundleDiscount { Percentage = _bundleDiscount }; return(discount == null ? new[] { bundleDiscount } : new[] { bundleDiscount, discount }); } }