Exemple #1
0
        public void TestPromotionsByCount()
        {
            var itemA = new OrderItem {
                SkuId = "A", Count = 5, Price = 50
            };
            var order = new Order();

            order.OrderItems.Add(itemA);
            order = _promotionFactory.ApplyPromotion(order);
            Assert.AreEqual(2, order.OrderItems[0].Count);
            Assert.AreEqual(1, order.PromoItems[0].Count);
            Assert.AreEqual(130, order.PromoItems[0].Price);
            Assert.AreEqual(50, order.OrderItems[0].Price);
        }
Exemple #2
0
        public void TestForScenarioA()
        {
            var itemA = _itemFactory.GetItem("A");

            itemA.Count = 1;
            var itemB = _itemFactory.GetItem("B");

            itemB.Count = 1;
            var itemC = _itemFactory.GetItem("C");

            itemC.Count = 1;
            var order = new Order();

            order.OrderItems.Add(itemA);
            order.OrderItems.Add(itemB);
            order.OrderItems.Add(itemC);

            order = _promotionFactory.ApplyPromotion(order);

            var invoiceAmount = _invoiceFactory.CalculateTotalInvoiceAmount(order);

            Assert.AreEqual(100, invoiceAmount);
        }