Пример #1
0
        public void Add(Product prod, int qty)
        {
            OrderItem oi = new OrderItem();

            oi.Product = prod;
            oi.Qty = qty;

            items.Add(oi);
        }
Пример #2
0
        public void D1WhenBuying2ApplyOnlyOnSecondItem()
        {
            Product p = new Product();
            p.Sku = "100.1";
            p.Name = "Umbrella";
            p.Price = 20;

            Order order = new Order();
            order.Add(p, 2);

            DiscountEngine de = new DiscountEngine();
            de.CalculateDiscount(order);

            Assert.AreEqual(6, order.Discount);
        }
Пример #3
0
        public void D1NotAppliedWhenBuying1Item()
        {
            //setup
            Product p = new Product();
            p.Sku = "100.1";
            p.Name = "Umbrella";
            p.Price = 20;

            Order order = new Order();
            order.Add(p,1);

            DiscountEngine de = new DiscountEngine();

            //exercise
            de.CalculateDiscount(order);

            //verify
            Assert.AreEqual(0, order.Discount);
        }