示例#1
0
        public void VirtualCatalogWorkingTest()
        {
            var catalogController   = new CatalogModuleCatalogsController(GetCatalogService(), GetSearchService(), null, GetPropertyService(), GetPermissionService());
            var categoryController  = new CatalogModuleCategoriesController(GetSearchService(), GetCategoryService(), GetPropertyService(), GetCatalogService());
            var listEntryController = new CatalogModuleListEntryController(GetSearchService(), GetCategoryService(), GetItemService(), null);

            //Create virtual catalog
            var catalogResult = catalogController.GetNewVirtualCatalog() as OkNegotiatedContentResult <webModel.Catalog>;
            var vCatalog      = catalogResult.Content;

            vCatalog.Name = "vCatalog1";
            catalogController.Update(vCatalog);

            Assert.IsTrue(vCatalog.Virtual);

            //Create virtual category
            var categoryResult = categoryController.GetNewCategory(vCatalog.Id) as OkNegotiatedContentResult <webModel.Category>;
            var vCategory      = categoryResult.Content;

            vCatalog.Name = "vCategory";
            categoryController.Post(vCategory);

            Assert.IsTrue(vCategory.Virtual);

            //Link category to virtual category
            var link = new webModel.ListEntryLink {
                ListEntryId = "40773cd0-f2de-462f-9041-da742a274c38", ListEntryType = "Category", CatalogId = vCatalog.Id, CategoryId = vCategory.Id
            };

            listEntryController.CreateLinks(new webModel.ListEntryLink[] { link });


            //Check result
            var serachResult = listEntryController.ListItemsSearch(new webModel.ListEntrySearchCriteria
            {
                CatalogId     = vCatalog.Id,
                CategoryId    = vCategory.Id,
                ResponseGroup = webModel.ResponseGroup.WithCategories
            })
                               as OkNegotiatedContentResult <webModel.ListEntrySearchResult>;
            var listResult = serachResult.Content;

            Assert.IsTrue(listResult.ListEntries.Any());
            var category = listResult.ListEntries.First();

            Assert.IsTrue(category.Id == "40773cd0-f2de-462f-9041-da742a274c38");

            //Remove link
            //listEntryController.DeleteLinks(new webModel.ListEntryLink[] { link });
        }
        public void VirtualCatalogWorkingTest()
        {

            var catalogController = new CatalogModuleCatalogsController(GetCatalogService(), GetSearchService(), null, GetPropertyService(), GetPermissionService());
            var categoryController = new CatalogModuleCategoriesController(GetSearchService(), GetCategoryService(), GetPropertyService(), GetCatalogService(), null);
            var listEntryController = new CatalogModuleListEntryController(GetSearchService(), GetCategoryService(), GetItemService(), null);

            //Create virtual catalog
            var catalogResult = catalogController.GetNewVirtualCatalog() as OkNegotiatedContentResult<webModel.Catalog>;
            var vCatalog = catalogResult.Content;
            vCatalog.Name = "vCatalog1";
            catalogController.Update(vCatalog);

            Assert.IsTrue(vCatalog.Virtual);

            //Create virtual category
            var categoryResult = categoryController.GetNewCategory(vCatalog.Id) as OkNegotiatedContentResult<webModel.Category>;
            var vCategory = categoryResult.Content;
            vCatalog.Name = "vCategory";
            categoryController.Post(vCategory);

            Assert.IsTrue(vCategory.Virtual);

            //Link category to virtual category
            var link = new webModel.ListEntryLink { ListEntryId = "40773cd0-f2de-462f-9041-da742a274c38", ListEntryType = "Category", CatalogId = vCatalog.Id, CategoryId = vCategory.Id };
            listEntryController.CreateLinks(new webModel.ListEntryLink[] { link });


            //Check result
            var serachResult = listEntryController.ListItemsSearch(new webModel.ListEntrySearchCriteria
            {
                CatalogId = vCatalog.Id,
                CategoryId = vCategory.Id,
                ResponseGroup = webModel.ResponseGroup.WithCategories
            })
                as OkNegotiatedContentResult<webModel.ListEntrySearchResult>;
            var listResult = serachResult.Content;

            Assert.IsTrue(listResult.ListEntries.Any());
            var category = listResult.ListEntries.First();
            Assert.IsTrue(category.Id == "40773cd0-f2de-462f-9041-da742a274c38");

            //Remove link
            //listEntryController.DeleteLinks(new webModel.ListEntryLink[] { link });

        }