Ejemplo n.º 1
0
 public static void Initialize(TestContext testContext)
 {
     //Setting up SKU's and Promotions
     PromotionStore.GetStore();
     AddSKUItems();
     AddPromotions();
 }
Ejemplo n.º 2
0
        public void TestPromotionStore()
        {
            PromotionStore promotionStore  = PromotionStore.GetStore();
            PromotionStore promotionStore2 = PromotionStore.GetStore();

            Assert.AreSame(promotionStore, promotionStore2);
        }
Ejemplo n.º 3
0
        public static void AddPromotions()
        {
            PromotionStore promotionStore = PromotionStore.GetStore();

            promotionStore.AddOrUpdatePromotion(new Promotion
            {
                PromotionId   = Guid.NewGuid(),
                promotionSKUs = new List <PromotionSKU> {
                    new PromotionSKU
                    {
                        Quantity = 3,
                        SKUId    = "A"
                    }
                },
                Name       = "3 X A = 130",
                PromoValue = 130
            });
            promotionStore.AddOrUpdatePromotion(new Promotion
            {
                PromotionId   = Guid.NewGuid(),
                promotionSKUs = new List <PromotionSKU> {
                    new PromotionSKU {
                        Quantity = 2, SKUId = "B"
                    }
                },
                Name       = "2 X B = 45",
                PromoValue = 45
            });
            promotionStore.AddOrUpdatePromotion(new Promotion
            {
                PromotionId   = Guid.NewGuid(),
                promotionSKUs = new List <PromotionSKU> {
                    new PromotionSKU
                    {
                        Quantity = 1,
                        SKUId    = "C"
                    },
                    new PromotionSKU
                    {
                        Quantity = 1,
                        SKUId    = "D"
                    }
                },
                Name       = "C + D = 30",
                PromoValue = 30
            });
        }
Ejemplo n.º 4
0
        public void TestOrder5()
        {
            PromotionStore promotionStore = PromotionStore.GetStore();

            promotionStore.AddOrUpdatePromotion(new Promotion
            {
                Name        = "0 X A = 0",
                PromotionId = Guid.NewGuid()
                ,
                promotionSKUs = new List <PromotionSKU>()
                {
                    new PromotionSKU {
                        SKUId = "A", Quantity = 0
                    },
                },
                PromoValue = 0
            });
            Order order = new Order()
            {
                OrderId = Guid.NewGuid(),
                SKUs    = new List <OrderSKUQuantity>
                {
                    new OrderSKUQuantity {
                        SKUId = "A", Quantity = 0
                    },
                    new OrderSKUQuantity {
                        SKUId = "B", Quantity = 5
                    },
                    new OrderSKUQuantity {
                        SKUId = "C", Quantity = 3
                    },
                    new OrderSKUQuantity {
                        SKUId = "D", Quantity = 1
                    },
                }
            };

            order.Process();
            //--        = 0
            //45+45+30  = 120
            //30+ 20*20 =  70
            //--        = 630
            Assert.AreEqual(order.TotalValue, 190);
        }
Ejemplo n.º 5
0
        public static void AddSKUItems()
        {
            PromotionStore promotionStore = PromotionStore.GetStore();

            promotionStore.AddOrUpdateSKUItem(new SKUItem()
            {
                SKUId = "A", UnitPrice = 50
            });
            promotionStore.AddOrUpdateSKUItem(new SKUItem()
            {
                SKUId = "B", UnitPrice = 30
            });
            promotionStore.AddOrUpdateSKUItem(new SKUItem()
            {
                SKUId = "C", UnitPrice = 20
            });
            promotionStore.AddOrUpdateSKUItem(new SKUItem()
            {
                SKUId = "D", UnitPrice = 15
            });
        }