Esempio n. 1
0
        public void FailSavePromotionCatalogTest()
        {
            try
            {
                var dict        = new Dictionary <Guid, IPromotion>();
                var dataContext = new JSonFileDataContext("", knownTypes);
                dataContext.SaveData(dict);

                Assert.Fail("File Path is invalid");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex != null);
            }
        }
Esempio n. 2
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. 3
0
        public void ReadEmptyPromotionCatalogTest()
        {
            try
            {
                var writeDict = new Dictionary <Guid, IPromotion>();
                CreatePromotionCatalogFile(writeDict);

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

                var dataContext = new JSonFileDataContext(promotionCatalogPath, knownTypes);
                var readDict    = dataContext.LoadData <IDictionary <Guid, IPromotion> >();

                Assert.IsNotNull(readDict);
                Assert.AreEqual(readDict.Count, 0);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Esempio n. 4
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());
            }
        }
Esempio n. 5
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());
            }
        }
Esempio n. 6
0
        void CreatePromotionCatalogFile(IDictionary <Guid, IPromotion> dict)
        {
            var dataContext = new JSonFileDataContext(promotionCatalogPath, knownTypes);

            dataContext.SaveData(dict);
        }