public void AddProductToCart_WhenPriceIsCalculated_PriceIsCorrect() { //ARRANGE _testcart.AddProductToCart(_testproduct); _testcart.AddProductToCart(_testproduct); _testcart.AddProductToCart(_testproduct); _testcart.AddProductToCart(_testproduct); //ACT double priceofcart = _testcart.CalculatePrice(); //ASSERT Assert.AreEqual(4.0 * 1.21, priceofcart); }
public void ShouldAddAProductToCart() { Product bread = new Product("Bread", 10.12m); Product[] products = { new Product("Milk", 12.10m) }; ShoppingCart cart = new ShoppingCart(products); cart.AddProductToCart(bread); Assert.AreEqual(2, cart.GetLength()); }
public void AddProductToCart_WhenCalledWithGivenStock_ThenCheckIfProductWillBeAddedToCart(int stock, int expectedResult) { //ARRANGE _testcart.ClearCart(); _testproduct = new GamingPc(1, "TestComputer", 1, "https://placekitten.com/200/300", "Test description", 0, 1, "TestMOBO", "TestHDD", "TestCPU", "TestPSU", "TestGPU", Performance.Affordable, true) { Stock = stock }; //ACT _testcart.AddProductToCart(_testproduct); //ASSERT Assert.AreEqual(expectedResult, _testcart.ShoppingList.Count); }
public void GamingPC_WhenStockIsZero_CanNotBeAddedToShoppingCart() { //ARRANGE //_testcart = ShoppingCart.GetShoppingCart(); //_testproduct = new GamingPc("TestComputer", 1, "https://placekitten.com/200/300", "Test description", 1, 1, "TestMOBO", // "TestHDD", "TestCPU", "TestPSU", "TestGPU", Performance.Affordable, true) //{ // Stock = 0 //}; //ACT //var output1 = testcart.ToString(); int number1InCart = _testcart.ShoppingList.Count; _testcart.AddProductToCart(_testproduct); int number2InCart = _testcart.ShoppingList.Count; //var output2 = testcart.ToString(); //ASSERT Assert.AreEqual(number1InCart, number2InCart); }
internal void AddProductToCart(Product product) { ShoppingCart.AddProductToCart(product); NotifyStoreMutated(); }