public void AddProduct_CorrectProduct_CorrectAdding() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 1M, 10); cartManager.AddProduct(product); Assert.IsTrue(cartManager.Products.Contains(product)); }
public void RemoveProduct_ProductIsContains_ProductRemoving() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 1M, 10); cartManager.AddProduct(product); cartManager.RemoveProduct(product); Assert.IsTrue(!cartManager.Products.Contains(product)); }
public void Undo_UndoAddProduct_ProductIsNotContains() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 1M, 10); cartManager.AddProduct(product); cartManager.Undo(); Assert.IsTrue(!cartManager.Products.Contains(product)); }
public void ChangeProductCount_SetNegativeCount_ThrowArgumentException() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 2M, 10); cartManager.AddProduct(product); cartManager.ChangeProductCount(product, 15); Assert.Throws <ArgumentException>(() => cartManager.ChangeProductCount(product, -5)); }
public void ChangeProductCount_SetCorrectCount_SetNewCount() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 2M, 10); cartManager.AddProduct(product); cartManager.ChangeProductCount(product, 15); Assert.IsTrue(product.Count == 15); }
public void ApplyProductCupon_UseCorrectProductCupon_ReturnCorrectProductTotalPrice() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 2M, 10); var cupon = new DiscountProductCupon(0.5M, 3); cartManager.AddProduct(product); cartManager.SetProductCupon(product, cupon); Assert.IsTrue(product.TotalPrice == 10M); }
public void Undo_UndoApplingCartCupon_ReturnCorrectCartTotalPrice() { var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 2M, 10); var cupon = new DiscountCartCupon(0.5M); cartManager.AddProduct(product); cartManager.SetCartCupon(cupon); cartManager.Undo(); Assert.IsTrue(cartManager.TotalPrice == 20M); }
public void GenerateReceipt_GenerateWithCorrectCartPasrameters_ReturnCorrectText() { const string expectedResult = "Tnx!\r\nName...price...count...summ\r\nbuble...1...10...8,0\r\nTotal: 4,00\r\n"; var cartManager = new ShoppingCartManager(new CommandManager()); var product = new VanilaCandy(1, "buble", 1M, 10); cartManager.AddProduct(product); cartManager.SetProductCupon(product, new DiscountProductCupon(0.8M, 3)); cartManager.SetCartCupon(new DiscountCartCupon(0.5M)); var result = new SomeReceiptGenerator().Generate(cartManager); Assert.IsTrue(result == expectedResult); }