public void TestBusinessLocationDecrementStockWhenProductNotInStock(int id, string address, string city, string zipcode, string state, int productId, string productName, decimal productPrice, int productStock) { BusinessLocation location = new BusinessLocation(); location.Id = id; location.Address = address; location.City = city; location.Zipcode = zipcode; location.State = state; BusinessProduct product = new BusinessProduct() { Id = productId, Name = productName, Price = productPrice }; location.AddProduct(product, productStock); BusinessProduct productNotInStock = new BusinessProduct() { Id = productId + 1, Name = productName + "a", Price = productPrice + 1 }; int quantity = 10; Assert.Throws <BusinessLocationException>(() => location.DecrementStock(productNotInStock, quantity)); }
public void TestBusinessLocationDecrementStock(int id, string address, string city, string zipcode, string state, int productId, string productName, decimal productPrice, int productStock) { BusinessLocation location = new BusinessLocation(); location.Id = id; location.Address = address; location.City = city; location.Zipcode = zipcode; location.State = state; BusinessProduct product = new BusinessProduct() { Id = productId, Name = productName, Price = productPrice }; location.AddProduct(product, productStock); int quantity = 1; location.DecrementStock(product, quantity); Assert.Equal(location.inventory[product], productStock - 1); }