public void AppliesAdjustment()
 {
     const decimal orderTotal = 100.0m;
       var applier = new DiscountCodeApplier(DiscountCode(10.0m));
       var adjustment = applier.DiscountAdjustment(orderTotal);
       Assert.IsNotNull(adjustment);
       Assert.AreEqual(-10.0m, adjustment.Amount);
 }
 public void ApplyDiscountCode(Order order, string code)
 {
     var discountCode = _discountCodeQueryService.FindByCode(code);
     var applier = new DiscountCodeApplier(discountCode);
     AddAdjustment(order, applier.DiscountAdjustment(order.Total));
     OrderCalculator.Calculate(order);
     _orderRepository.Update(order);
 }
        public void ApplyDiscountCode(Order order, string code)
        {
            var discountCode = _discountCodeQueryService.FindByCode(code);
            var applier      = new DiscountCodeApplier(discountCode);

            AddAdjustment(order, applier.DiscountAdjustment(order.Total));
            OrderCalculator.Calculate(order);
            _orderRepository.Update(order);
        }
 public void IgnoresUpcomingDiscountCode()
 {
     const decimal orderTotal = 100.0m;
       var applier = new DiscountCodeApplier(UpcomingDiscountCode(10.0m));
       Assert.AreEqual(100.0m, applier.DiscountedTotal(orderTotal));
 }
 public void IgnoresInactiveDiscountCode()
 {
     const decimal orderTotal = 100.0m;
       var applier = new DiscountCodeApplier(DiscountCode(10.0m, false));
       Assert.AreEqual(100.0m, applier.DiscountedTotal(orderTotal));
 }
 public void DiscountedTotalFromPercentageCannotBeLessThanZero()
 {
     const decimal orderTotal = 100.0m;
       var applier = new DiscountCodeApplier(PercentageDiscountCode(110.0m));
       Assert.AreEqual(0.0m, applier.DiscountedTotal(orderTotal));
 }
 public void CalculatesDiscountTotalFromPercentage()
 {
     const decimal orderTotal = 150.0m;
       var applier = new DiscountCodeApplier(PercentageDiscountCode(20.0m));
       Assert.AreEqual(120.0m, applier.DiscountedTotal(orderTotal));
 }
 public void CalculatesDiscountTotal()
 {
     const decimal orderTotal = 100.0m;
       var applier = new DiscountCodeApplier(DiscountCode(10.0m));
       Assert.AreEqual(90.0m, applier.DiscountedTotal(orderTotal));
 }