public void JustTest() { // SETUP ITEMS List <Item> _items = new List <Item>() { new Item() { ProductName = "A", Price = 10, Quantity = 10 }, new Item() { ProductName = "B", Price = 20, Quantity = 3 } }; _items.Add(new Item() { ProductName = "B", Price = 20, Quantity = 7 }); var userCart = new UserCart(); foreach (var item in _items) { userCart.AddItem(item); } // SETUP DISCOUNTS List <Discount> discounts = new List <Discount>(); discounts.Add(new Discount() { Product = "A", Percentage = 50, Threshold = 3 }); discounts.Add(new Discount() { Product = "B", Percentage = 25, Threshold = 4 }); // AFTER DISCOUNT TOTAL PRICE // A: 85 // B: 190 // TOTAL: 275 userCart.ApplyDiscounts(discounts); Assert.AreEqual(userCart.TotalPrice(), 275); }
public void ProvideDiscountToCustomer() { // SETUP ITEMS List <Item> _items = new List <Item>() { new Item() { ProductName = "A", Price = 10, Quantity = 4 }, new Item() { ProductName = "B", Price = 20, Quantity = 4 } }; // SETUP DISCOUNTS List <Discount> discounts = new List <Discount>(); discounts.Add(new Discount() { Product = "A", Percentage = 50, Threshold = 3 }); discounts.Add(new Discount() { Product = "B", Percentage = 25, Threshold = 4 }); // AFTER DISCOUNT TOTAL PRICE // A: 35 // B: 75 // TOTAL: 110 var userCart = new UserCart(); foreach (var item in _items) { userCart.AddItem(item); } Assert.AreEqual(userCart.TotalPrice(), 120); userCart.ApplyDiscounts(discounts); Assert.AreEqual(userCart.TotalPrice(), 110); }