public void ShouldUpdateExistentProduct() { var createdProduct = CreateNewProduct(); UpdateProduct updateProduct = new UpdateProduct(); createdProduct.Name = "Updated"; updateProduct.InputArgument = createdProduct; updateProduct.Execute(); CommitDatabaseChanges.Commit(); GetProduct getProduct = new GetProduct(); getProduct.InputArgument = p => p.Name == "Updated"; getProduct.Execute(); Assert.IsTrue(getProduct.OutputArgument.Count > 0); }
public void ShouldPreventUpdateWithInconvenientPrice() { var createdProduct = CreateNewProduct("product code 1"); CommitDatabaseChanges.Commit(); UpdateProduct updateProduct = new UpdateProduct(); createdProduct.Price = 0; updateProduct.InputArgument = createdProduct; try { updateProduct.Execute(); Assert.Fail("Product price should be greater than zero."); } catch (ProductPriceValidationException) { Assert.Pass(); } }
public void ShouldPreventUpdateWithSameProductCode() { var createdProduct = CreateNewProduct(); CommitDatabaseChanges.Commit(); var createAnotherProduct = CreateNewProduct("product code 2"); CommitDatabaseChanges.Commit(); createAnotherProduct.Code = "product code 1"; UpdateProduct updateProduct = new UpdateProduct(); updateProduct.InputArgument = createAnotherProduct; try { updateProduct.Execute(); Assert.Fail("Existed product code cannot be updated."); } catch (DuplicateProductException) { Assert.Pass(); } }