Esempio n. 1
0
        //    cate1  cate2    =>   cate1 cate2
        //    /                            \
        //  cate3                         cate3
        public void UpdateCategoryTest10()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate1 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate1.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly));
            var cate2 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate2.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate1.Id);
            var cate3 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate3.Id.Value);

            cate3.ParentCategoryId = cate2.Id;
            var updateCate = CategoryFactory.UpdateCategory(ApiMsgHandler, cate3, cate3.Id.Value, null);

            Assert.AreEqual(cate2.Id, updateCate.ParentCategoryId);

            //verify its old parent
            var getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate1.Id.Value);

            Assert.AreEqual(0, getCate.ChildCount.Value);

            //verify its new parent
            getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate2.Id.Value);
            Assert.AreEqual(1, getCate.ChildCount.Value);
        }
Esempio n. 2
0
        public void DeleteCategoryTest1()
        {
            //cascadeDelete = null
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate4 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, null, expectedCode: HttpStatusCode.NoContent);
            CategoryFactory.GetCategory(ApiMsgHandler, cate4.Id.Value, expectedCode: HttpStatusCode.NotFound);
            //cascadeDelete = false
            cateObj = Generator.GenerateCategory(Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly));
            var cate1 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate1.Id.Value);
            cate4 = CategoryFactory.AddCategory(ApiMsgHandler, Generator.GenerateCategory("cate4"));
            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, false, expectedCode: HttpStatusCode.NoContent);
            CategoryFactory.GetCategory(ApiMsgHandler, cate4.Id.Value, expectedCode: HttpStatusCode.NotFound);
            var result = CategoryFactory.GetCategory(ApiMsgHandler, cate1.Id.Value);

            //cascadeDelete = true
            cateObj = Generator.GenerateCategory(Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly));
            var cate2 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate2.Id.Value);
            cate4 = CategoryFactory.AddCategory(ApiMsgHandler, Generator.GenerateCategory("cate4"));
            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, true, expectedCode: HttpStatusCode.NoContent);
            CategoryFactory.GetCategory(ApiMsgHandler, cate4.Id.Value, expectedCode: HttpStatusCode.NotFound);
            result = CategoryFactory.GetCategory(ApiMsgHandler, cate2.Id.Value);
        }
Esempio n. 3
0
        public void CreateCategoryTest2()
        {
            if (TestBaseTenant.MasterCatalogs.First().Catalogs.Count < 2)
            {
                Assert.Inconclusive("The sites are less than 2");
            }
            var cates       = CategoryFactory.GetCategories(ApiMsgHandler);
            int count_site1 = (int)cates.TotalCount;

            //add a category to another site
            var msgHandler2 = ServiceClientMessageFactory.GetTestClientMessage(TestBaseTenant.Id, TestBaseTenant.MasterCatalogs.First().Id, TestBaseTenant.MasterCatalogs.First().Catalogs.Last().Id);

            cates = CategoryFactory.GetCategories(msgHandler2);
            int count_site2 = (int)cates.TotalCount;
            var cate        = CategoryFactory.AddCategory(msgHandler2, Generator.GenerateCategory(Generator.RandomString(5,
                                                                                                                         Generator
                                                                                                                         .RandomCharacterGroup
                                                                                                                         .AlphaOnly)));

            cateIds2.Add(cate.Id.Value);
            // verify the group category added to
            cates = CategoryFactory.GetCategories(msgHandler2);
            Assert.AreEqual(1 + count_site2, cates.TotalCount);

            // verify category total count for the not
            cates = CategoryFactory.GetCategories(ApiMsgHandler);
            Assert.AreEqual(count_site1, cates.TotalCount);
        }
Esempio n. 4
0
        public void CreateCategoryTest7()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));

            cateObj.Sequence = Generator.RandomInt(1, 10);
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            Assert.AreEqual(cateObj.Sequence, cate.Sequence);
        }
Esempio n. 5
0
        public void CreateCategoryTest5()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));

            cateObj.ProductCount = Generator.RandomInt(1, 5);
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            Assert.AreEqual(0, cate.ProductCount);
        }
Esempio n. 6
0
        public void CreateCategoryTest3()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));

            cateObj.Id = Generator.RandomInt(20, 50);
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            Assert.AreNotEqual(cateObj.Id, cate.Id);
        }
Esempio n. 7
0
        public void GetChildCategoriesTest2()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var createdCategory = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(createdCategory.Id.Value);
            var childCates = CategoryFactory.GetChildCategories(ApiMsgHandler, (int)createdCategory.Id);

            Assert.AreEqual(0, childCates.TotalCount);
        }
Esempio n. 8
0
        public void UpdateCategoryTest6()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);

            cate.Content = Generator.GenerateCategoryLocalizedContent(Generator.RandomString(5, Generator.RandomCharacterGroup.AlphaOnly));
            var updateCate = CategoryFactory.UpdateCategory(ApiMsgHandler, cate, cate.Id.Value, null);

            Assert.AreEqual(cate.Content.Name, updateCate.Content.Name);
        }
Esempio n. 9
0
        public void UpdateCategoryTest3()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            int original = cate.ProductCount ?? 0;

            cate.ProductCount = original + Generator.RandomInt(1, 5);
            var updateCate = CategoryFactory.UpdateCategory(ApiMsgHandler, cate, cate.Id.Value, null);

            Assert.AreEqual(original, updateCate.ProductCount);
        }
Esempio n. 10
0
        public void CreateCategoryTest8()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var audit = Generator.GenerateAuditInfoRandom();

            cateObj.AuditInfo = audit;
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            Assert.AreNotEqual(audit.CreateBy, cate.AuditInfo.CreateBy);
            Assert.AreNotEqual(((DateTime)audit.CreateDate).Date, ((DateTime)cate.AuditInfo.CreateDate).Date);
            Assert.AreNotEqual(audit.UpdateBy, cate.AuditInfo.UpdateBy);
            Assert.AreNotEqual(((DateTime)audit.UpdateDate).Date, ((DateTime)cate.AuditInfo.UpdateDate).Date);
        }
Esempio n. 11
0
        public void CreateCategoryTest6()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));

            cateObj.IsDisplayed = false;
            var cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate.Id.Value);
            Assert.IsFalse((bool)cate.IsDisplayed);

            cateObj.IsDisplayed = true;
            cate = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);
            cateIds1.Add(cate.Id.Value);
            Assert.IsTrue((bool)cate.IsDisplayed);
        }
Esempio n. 12
0
        public void UpdateCategoryTest4()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate1 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate1.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate1.Id);
            var cate2 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate2.Id.Value);

            cate1.IsDisplayed = false;
            CategoryFactory.UpdateCategory(ApiMsgHandler, cate1, cate1.Id.Value, cascadeVisibility: false,
                                           expectedCode: HttpStatusCode.Conflict);
        }
Esempio n. 13
0
        //         cate1
        //       /
        //    cate2
        //    /
        //  cate3
        //   /
        //  cate4
        public void UpdateCategoryTest5()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate1 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate1.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate1.Id);
            var cate2 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate2.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate2.Id);
            var cate3 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate3.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate3.Id);
            var cate4 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate4.Id.Value);

            cate2.IsDisplayed = false;
            CategoryFactory.UpdateCategory(ApiMsgHandler, cate2, cate2.Id.Value, cascadeVisibility: true);

            //its parent should not change
            var getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate1.Id.Value);

            Assert.IsTrue(getCate.IsDisplayed.Value);

            // verify its sons
            getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate3.Id.Value);
            Assert.IsFalse(getCate.IsDisplayed.Value);

            // verify its grandsons
            getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate4.Id.Value);
            Assert.IsFalse(getCate.IsDisplayed.Value);
        }
Esempio n. 14
0
        public void DeleteCategoryTest3()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate4     = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);
            var myPT      = Generator.GenerateBasicProductType(Generator.RandomString(10, Generator.RandomCharacterGroup.AlphaOnly));
            var createdPT = ProductTypeFactory.AddProductType(ApiMsgHandler, myPT);

            productTypeIds.Add(createdPT.Id.Value);
            var product        = Generator.GenerateProduct(createdPT);
            var createdProduct = ProductFactory.AddProduct(ApiMsgHandler, product);

            productCode1.Add(createdProduct.ProductCode);
            var proInfo = Generator.GenerateProductInCatalogInfo(TestBaseTenant.MasterCatalogs.First().Catalogs.First().Id, cate4.Id, true);

            ProductFactory.AddProductInCatalog(ApiMsgHandler, proInfo, createdProduct.ProductCode);
            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, false, expectedCode: HttpStatusCode.Conflict);
            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate4.Id.Value, true, expectedCode: HttpStatusCode.NoContent);
            ProductFactory.GetProduct(ApiMsgHandler, product.ProductCode);
        }
Esempio n. 15
0
        //         cate1
        //       /
        //    cate2
        //    /
        //  cate3
        //   /
        //  cate4
        public void DeleteCategoryTest2()
        {
            var cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                            Generator.RandomCharacterGroup.AlphaOnly));
            var cate1 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            cateIds1.Add(cate1.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate1.Id);
            var cate2 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            //cateIds1.Add(cate2.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate2.Id);
            var cate3 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            //cateIds1.Add(cate3.Id.Value);

            cateObj = Generator.GenerateCategory(Generator.RandomString(5,
                                                                        Generator.RandomCharacterGroup.AlphaOnly), parentCategoryId: cate3.Id);
            var cate4 = CategoryFactory.AddCategory(ApiMsgHandler, cateObj);

            //cateIds1.Add(cate4.Id.Value);

            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate2.Id.Value, false, expectedCode: HttpStatusCode.Conflict);
            CategoryFactory.DeleteCategoryById(ApiMsgHandler, cate2.Id.Value, true, expectedCode: HttpStatusCode.NoContent);

            //its parent should not change
            var getCate = CategoryFactory.GetCategory(ApiMsgHandler, cate1.Id.Value);

            Assert.AreEqual(0, getCate.ChildCount);

            // verify its sons
            CategoryFactory.GetCategory(ApiMsgHandler, cate3.Id.Value, expectedCode: HttpStatusCode.NotFound);

            // verify its grandsons
            CategoryFactory.GetCategory(ApiMsgHandler, cate4.Id.Value, expectedCode: HttpStatusCode.NotFound);
        }