public void Success_UpdateProduct() { //Arrange int index; string result; Product product; //Act index = 504; product = new Product { Name = "ClassLibrary1 - Test product database - UpdateProduct", Price = product_price + index }; result = db_product.CreateProduct(product); if (result.Equals("Success")) { product.Price += 0.5; product.Id = db_product.FindProductByName(product.Name)[0].Id; result = db_product.UpdateProduct(product); } //Assert Assert.AreEqual("Success", result); }
/// <summary> /// Updates a product. /// </summary> /// <param name="product"></param> /// <returns>string</returns> public string Update(Product product) { string result; if (FindById(product.Id).Equals(product)) { result = db_product.UpdateProduct(product); } else { result = "The product doesn't exist."; } return(result); }