public Product Retreive(int productId) { //code that retreives the defined customer Product product = new Product(productId); if (productId == 2) { product.ProductName = "xxx"; product.ProductDescription = "xxx"; product.CurrentPrice = 15.96M; } return product; }
public bool Save(Product product) { //code that saves the defined customer var success = true; if (product.HasChanges && product.IsValid) { if (product.IsNew) { //call an insert stored procedure } else { //call an update stored procedure } } return success; }
public void RetreiveExisting() { //Arrange var productRepository = new ProductRepository(); var expected = new Product(2) { ProductName = "xxx", ProductDescription = "xxx", CurrentPrice = 15.96M }; //Act var actual = productRepository.Retreive(2); //Assert Assert.AreEqual(expected.ProductId, actual.ProductId); Assert.AreEqual(expected.ProductName, actual.ProductName); Assert.AreEqual(expected.ProductDescription, actual.ProductDescription); Assert.AreEqual(expected.CurrentPrice, actual.CurrentPrice); }