public void SelectById_ProductId_ReturnsProduct() { //arrange CollectionProductModel model = new CollectionProductModel(); Product product = new Product("p1", "Dog Dinner", 1.20); model.Create(product); //act Product retrievedProduct = model.SelectById("p1"); //assert Assert.NotNull(retrievedProduct); Assert.Equal(product, retrievedProduct); }
public void Delete_IdOfProduct_RemovesProductFromCollection() { //arrange CollectionProductModel model = new CollectionProductModel(); Product product = new Product("p1", "Dog Dinner", 1.20); model.Create(product); //act bool deleted = model.Delete("p1"); //assert Product retrievedProduct = model.SelectById("p1"); Assert.Null(retrievedProduct); Assert.True(deleted); }
public void Update_Product_ModifiesProductInCollection() { //arrange CollectionProductModel model = new CollectionProductModel(); Product product = new Product("p1", "Dog Dinner", 1.20); Product updatedProduct = new Product("p1", "Dog Dinner", 1.40); model.Create(product); //act bool updated = model.Update(updatedProduct); //assert Product retrievedProduct = model.SelectById("p1"); Assert.NotNull(retrievedProduct); Assert.Equal(1.40, retrievedProduct.CostPrice); Assert.True(updated); }