public void AddTwoSameProductsToCart() { CartController cart = new CartController(); cart.AddCartProduct(1); cart.AddCartProduct(1); Assert.That(cart.GetCartProducts(1)[0].Quantity, Is.EqualTo(2)); }
public void CaseA() { CartController cart = new CartController(); cart.AddCartProduct(3); cart.AddCartProduct(2); cart.AddCartProduct(1); Assert.That(cart.GetTotalPrice(), Is.EqualTo((double)2.95)); }
public void CalculateTotalPrice() { CartController cart = new CartController(); cart.AddCartProduct(2); cart.AddCartProduct(2); cart.AddCartProduct(2); Assert.That(cart.GetTotalPrice(), Is.EqualTo(Math.Round(ProductRepository.GetProduct(2).Price * 3, 2))); }
public void AddTwoProductsAndDeleteOne() { CartController cart = new CartController(); cart.AddCartProduct(1); cart.AddCartProduct(1); cart.RemoveCartProduct(1); Assert.That(cart.GetCartProducts(1)[0].Quantity, Is.EqualTo(1)); }
public void AddFourMilksFourthShouldBeFree() { CartController cart = new CartController(); cart.AddCartProduct(2); cart.AddCartProduct(2); cart.AddCartProduct(2); cart.AddCartProduct(2); Assert.Multiple(() => { Assert.That(cart.GetTotalPrice(), Is.EqualTo(Math.Round(ProductRepository.GetProduct(2).Price * 3, 2))); Assert.That(cart.GetCartProducts(2).Single(p => p.IsPromotion).Price, Is.EqualTo(0)); }); }
public void CaseD() { CartController cart = new CartController(); cart.AddCartProduct(1); cart.AddCartProduct(1); cart.AddCartProduct(3); for (int i = 0; i < 8; i++) { cart.AddCartProduct(2); } Assert.That(cart.GetTotalPrice(), Is.EqualTo((double)9)); }
static void Main(string[] args) { var cart = new CartController(); cart.AddCartProduct(1); cart.AddCartProduct(1); cart.AddCartProduct(3); for (int i = 0; i < 8; i++) { cart.AddCartProduct(2); } cart.RemoveCartProduct(1); cart.RemoveCartProduct(1); Console.WriteLine(cart.GetTotalPrice()); cart.RemoveCartProduct(2); }