public void UpdateProductCategory_with_values_saves_all_data_correctly() { ProductCategory category = new AnonymousProductCategoryBuilder(true).build(); //save the product category to the webshop string result = WebMethods.ProductCategoryMethods.UpdateProductCategory(category); result = XElement.Parse(result).Value; Assert.IsTrue(result == "ok", string.Format("Product Category with id {0} could not be created/updated. Unexpected return value was: {1}", category.Id, result)); //retrieve the category from the webshop string errorMsg; ProductCategory categoryFromWS = WebMethods.ProductCategoryMethods.GetProductCategoryById(category.Id, out errorMsg); //compare all values Assert.AreEqual(category.Id, categoryFromWS.Id, "The field comparison for field \"id\" failed."); Assert.AreEqual(category.Name, categoryFromWS.Name, "The field comparison for field \"name\" failed."); Assert.AreEqual(category.ParentId, categoryFromWS.ParentId, "The field comparison for field \"parent_id\" failed."); Assert.AreEqual(category.Test, categoryFromWS.Test, "The field comparison for field \"test\" failed."); Assert.AreEqual(category.TargetUrl, categoryFromWS.TargetUrl, "The field comparison for field \"target_url\" failed."); Assert.AreEqual(category.CreatedDttm, categoryFromWS.CreatedDttm, "The field comparison for field \"created\" failed."); Assert.AreEqual(category.UpdatedDttm, categoryFromWS.UpdatedDttm, "The field comparison for field \"updated\" failed."); Assert.AreEqual(category.DeletedDttm, categoryFromWS.DeletedDttm, "The field comparison for field \"deleted\" failed."); }
public void DeleteProductCategoryById_with_associated_products_returns_error() { //create test category ProductCategory category = new AnonymousProductCategoryBuilder(true).build(); string result = WebMethods.ProductCategoryMethods.UpdateProductCategory(category); result = XElement.Parse(result).Value; Assert.IsTrue(result == "ok", string.Format("Product Category with id {0} could not be created/updated. Unexpected return value: {1}", category.Id, result)); //set a test product linked to the test category var newProduct = new AnonymousProductBuilder(true).build(); newProduct.ProductCategories[0] = category; result = WebMethods.ProductMethods.UpdateProduct(newProduct); result = XElement.Parse(result).Value; Assert.IsTrue(result == "ok", string.Format("Product with id {0} could not be created/updated. Unexpected return value: {1}", newProduct.Id, result)); //delete the test category result = WebMethods.ProductCategoryMethods.DeleteProductCategoryById(category.Id); result = XElement.Parse(result).Value; Assert.IsTrue(result.StartsWith("error"), string.Format("ProductCategory with id {0} was deleted, even though a product was associated with it. Unexpected return value: {1}", category.Id, result)); }
public void UpdateProductCategory_creates_new_category_with_valid_parent_id_and_returns_ok() { ProductCategory category = new AnonymousProductCategoryBuilder(true).build(); string result = WebMethods.ProductCategoryMethods.UpdateProductCategory(category); result = XElement.Parse(result).Value; Assert.IsTrue(result == "ok", string.Format("ProductCategory with id {0} could not be created/updated. Unexpected return value: {1}", category.Id, result)); }