public void TestAffiliateDiscount()
        {
            var orderMgm = new OrderManagement(_repository);

            Order order = new Order();
            order.UserId = 2;//Affiliate
            order.Id = OrderManagement.CreateOrderId();
            //Add Items
            order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 20 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 40 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 10 });

            orderMgm.ProcessOrder(order);

            //Expectation
            //GrossAmount=70
            //Discount=10% of non grocery items discount = 10% of 20=2
            //Net Amount= 70-2=68
            Assert.AreEqual(70, order.GrossAmount);
            Assert.AreEqual(68, order.NetPayableAmount);
            Assert.AreEqual(2, order.TotalDiscount);
        }
        public void TestPercentageDiscountAppliedOnGrocery()
        {
            var orderMgm = new OrderManagement(_repository);
            Order order = new Order();
            order.UserId = 1;//employee
            order.Id = OrderManagement.CreateOrderId();
            //Add Items
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 1, Price = 200 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 250 });

            orderMgm.ProcessOrder(order);

            //All items are grocery
            //Only this will be applicable: "For every $100 on the bill, there would be a $ 5 discount"

            Assert.AreEqual(850, order.GrossAmount);
            Assert.AreEqual(810, order.NetPayableAmount);
            Assert.AreEqual(40, order.TotalDiscount);
        }
        public void TestOldCustomerDiscount()
        {
            var orderMgm = new OrderManagement(_repository);

            Order order = new Order();
            order.UserId = 3;//Old Customer
            order.Id = OrderManagement.CreateOrderId();
            //Add Items
            order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });

            orderMgm.ProcessOrder(order);

            //Expectation
            //discount on apparel 10% = 20
            //discount amount 7*5=35
            //totaldiscount=45
            Assert.AreEqual(750, order.GrossAmount);
            Assert.AreEqual(695, order.NetPayableAmount);
            Assert.AreEqual(55, order.TotalDiscount);
        }
 public void TestNullOrder()
 {
     var orderMgm = new OrderManagement(_repository);
     Order order = null;
     orderMgm.ProcessOrder(order);
 }
        public void TestNormalCustomerDiscount()
        {
            var orderMgm = new OrderManagement(_repository);

            Order order = new Order();
            order.UserId = 4;//Normal Customer
            order.Id = OrderManagement.CreateOrderId();
            //Add Items
            order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });

            orderMgm.ProcessOrder(order);

            //Expectation
            Assert.AreEqual(750, order.GrossAmount);
            Assert.AreEqual(715, order.NetPayableAmount);
            Assert.AreEqual(35, order.TotalDiscount);
        }
        public void TestIfUserIsAssociatedWithOrder()
        {
            var orderMgm = new OrderManagement(_repository);
            Order order = new Order();

            order.Id = OrderManagement.CreateOrderId();
            //Add Items
            order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
            //Add grocery Item
            order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });

            orderMgm.ProcessOrder(order);
        }
 public void TestIfUserIdIsNotAvailable()
 {
     var orderMgm = new OrderManagement(_repository);
     Order order = new Order();
     order.UserId = 10;
     orderMgm.ProcessOrder(order);
 }