Example #1
0
        Dictionary <Guid, IPromotion> CreatePromotionCatalog()
        {
            var promo1 = new SalePromotion(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(1), Guid.Parse("e1d57fe0-74b0-4d92-8b76-1e895ea563d4"), 0.50M, "Gala Apple Sale");
            var promo2 = new BatchPromotion(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(1), Guid.Parse("640d4eb6-f537-4a22-9690-15792f6509f9"), "Honey - Buy 1 get on 1/2 off Sale", new BogoDiscountCalculator(1, 0.5M));
            var promo3 = new BatchPromotion(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(1), Guid.Parse("ff9a9441-8a08-4ddd-9009-d7d5222434bc"), "Bunch 'O' cheese Sale", new GroupDiscountCalculator(3, 8.55M));
            var promo4 = new SalePromotion(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2), Guid.Parse("ad04ff83-5f0b-4092-ae69-d432c3446821"), 0.17M, "Banana Sale");

            return(new Dictionary <Guid, IPromotion>
            {
                { promo1.ItemId, promo1 },
                { promo2.ItemId, promo2 },
                { promo3.ItemId, promo3 },
                { promo4.ItemId, promo4 }
            });
        }
Example #2
0
        public void PassBatchInitializationTest()
        {
            try
            {
                var start = DateTime.Today;
                var end   = DateTime.Today.AddDays(1);
                var id    = Guid.NewGuid();
                var calc  = new BogoDiscountCalculator(0, 0);

                var batchPromo = new BatchPromotion(start, end, id, "Test", calc);

                Assert.IsNotNull(batchPromo);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Example #3
0
        public void PassBatchGroupDiscountTest()
        {
            try
            {
                var start = DateTime.Today;
                var end   = DateTime.Today.AddDays(1);
                var id    = Guid.NewGuid();
                var calc  = new GroupDiscountCalculator(3, 10M);

                var batchPromo = new BatchPromotion(start, end, id, "Test", calc);
                var actual     = batchPromo.CalculateBatchPrice(15, 3);

                Assert.AreEqual(15, actual);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }