public void WorkingWithCatalogPropertyTest() { var catalogController = new CatalogModuleCatalogsController(GetCatalogService(), GetSearchService(), null, GetPropertyService(), GetPermissionService()); var categoryController = new CatalogModuleCategoriesController(GetSearchService(), GetCategoryService(), GetPropertyService(), GetCatalogService(), null); var propertyController = new CatalogModulePropertiesController(GetPropertyService(), GetCategoryService(), GetCatalogService()); var productController = new CatalogModuleProductsController(GetItemService(), GetPropertyService(), null, null, null); var listEntryController = new CatalogModuleListEntryController(GetSearchService(), GetCategoryService(), GetItemService(), null); //var propertyResult = propertyController.GetNewCatalogProperty("Apple") as OkNegotiatedContentResult<webModel.Property>; //var property = propertyResult.Content; //property.Name = "CLP_Test2"; //property.Type = webModel.PropertyType.Product; //propertyController.Post(property); var catalogResult = catalogController.Get("Apple") as OkNegotiatedContentResult<webModel.Catalog>; var catalog = catalogResult.Content; catalog.Properties[0].Values.Add(new webModel.PropertyValue { Value = "sssss", ValueType = PropertyValueType.ShortText }); catalogController.Update(catalog); var serachResult = listEntryController.ListItemsSearch(new webModel.ListEntrySearchCriteria { CatalogId = "Apple", CategoryId = "186d61d8-d843-4675-9f77-ec5ef603fda3", ResponseGroup = webModel.ResponseGroup.Full }) as OkNegotiatedContentResult<webModel.ListEntrySearchResult>; var listResult = serachResult.Content; var listEntryProduct = listResult.ListEntries.OfType<webModel.ListEntryProduct>().FirstOrDefault(); var product = (productController.Get(listEntryProduct.Id) as OkNegotiatedContentResult<webModel.Product>).Content; }
public void AssociationTest() { //Get all product associations var productController = new CatalogModuleProductsController(GetItemService(), GetPropertyService(), null, null, null); var productResult = productController.Get("v-b004y45rxi") as OkNegotiatedContentResult<webModel.Product>; var product = productResult.Content; Assert.IsFalse(product.Associations.Any()); //Add association var association = new webModel.ProductAssociation { ProductId = "v-b0007zl6ds", Name = "Related Items" }; product.Associations.Add(association); productController.Update(product); //Remove product.Associations.Remove(product.Associations.Last()); productController.Update(product); }