Esempio n. 1
0
        public void PassPromotionCatalogInitTest()
        {
            try
            {
                CreatePromotionCatalogFile(CreatePromotionCatalog());
                var dataContext = new JSonFileDataContext(promotionCatalogPath, knownTypes);

                var promotionCatalog = new PromotionCatalog(dataContext);

                promotionCatalog.LoadCatalog();

                Assert.IsNotNull(promotionCatalog);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Esempio n. 2
0
        public void PassPromtionCatalogLoadFullTest()
        {
            try
            {
                var virtualCatalog = CreatePromotionCatalog();
                CreatePromotionCatalogFile(virtualCatalog);
                var dataContext = new JSonFileDataContext(promotionCatalogPath, knownTypes);

                var promotionCatalog = new PromotionCatalog(dataContext);

                foreach (var key in virtualCatalog.Keys)
                {
                    Assert.IsNotNull(promotionCatalog.ItemExists(key));
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        public void RemoveInvalidPromotionsShouldRemoveAllInvalidPromotions()
        {
            var catalog = new PromotionCatalog()
            {
                SalesLineItemDiscounts = new List <SalesLineItemDiscount>()
                {
                    new SalesLineItemDiscount()
                    {
                        Discount          = "$1",
                        EffectiveFrom     = DateTime.Now.AddHours(-10),
                        EffectiveTo       = DateTime.Now.AddHours(10),
                        ProductId         = "Tylenol",
                        ThresholdQuantity = 0 // invalid
                    },
                    new SalesLineItemDiscount()
                    {
                        Discount          = "~~~$1~~~", // invalid
                        EffectiveFrom     = DateTime.Now.AddHours(-10),
                        EffectiveTo       = DateTime.Now.AddHours(10),
                        ProductId         = "Advil",
                        ThresholdQuantity = 1
                    },
                    new SalesLineItemDiscount()
                    {
                        Discount          = "$1",
                        EffectiveFrom     = DateTime.Now.AddHours(-10),
                        EffectiveTo       = DateTime.Now.AddHours(10),
                        ProductId         = "Motrin",
                        ThresholdQuantity = 1
                    }
                }
            };

            catalog.RemoveInvalidPromotions();

            Assert.That(catalog.SalesLineItemDiscounts.Count, Is.EqualTo(1),
                        "Expect that the only a single valid promotion is left in the catalog.");
        }
Esempio n. 4
0
        public void PassPromotionCatalogSaveFullTest()
        {
            try
            {
                var virtualCatalog = CreatePromotionCatalog();
                CreatePromotionCatalogFile(virtualCatalog);
                var dataContext = new JSonFileDataContext(promotionCatalogPath, knownTypes);

                var promotionCatalog = new PromotionCatalog(dataContext);

                File.Delete(promotionCatalogPath);

                Assert.IsTrue(!File.Exists(promotionCatalogPath));

                promotionCatalog.SaveCatalog(virtualCatalog);

                Assert.IsTrue(File.Exists(promotionCatalogPath));
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }