public void IncentiveService_ProcessCoupon_Should_Take_20_Percent_Off_TestOrder() { IIncentive i = _incentiveService.GetIncentive("2"); Order order = GetTestOrder(); decimal before = order.SubTotal; decimal after = before - before * .2M; _incentiveService.ProcessCoupon("2", order); Assert.AreEqual(order.SubTotal, after); }
public void IncentiveService_Should_Return_Incentive_2_20_Percent_Off_Coupon() { IIncentive i = _incentiveService.GetIncentive("2"); Order order = GetTestOrder(); decimal before = order.SubTotal; decimal after = before - before * .2M; i.Coupon.ApplyCoupon(order); Assert.AreEqual(order.SubTotal, after); }
/// <summary> /// Processes a coupon for an order /// </summary> public void ProcessCoupon(string couponCode, Order order) { //get the incentive IIncentive i = GetIncentive(couponCode); if (i != null) { IIncentive check = order.IncentivesUsed.Where(x => x.Code.Equals(couponCode, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault(); if (check == null) { //make sure it's valid //this will throw //let it i.ValidateUse(order); i.Coupon.ApplyCoupon(order); order.IncentivesUsed.Add(i); order.DiscountReason = "Coupon " + couponCode + " applied"; } } }
public void IncentiveService_Should_Return_Incentive_1() { IIncentive i = _incentiveService.GetIncentive("1"); Assert.IsNotNull(i); }