public void TestGetProductList() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(15)); Cart cart = CartHelper.CreateNotEmptyCart(list); bool equalityCheckResult = true; for (int i = 0; i < cart.ItemsList.Count; i++) { if (cart.ItemsList[i].Equals(list[i])) { continue; } else { equalityCheckResult = false; } } Assert.IsTrue(equalityCheckResult); }
public void TestBowlDiscount() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddLargeBowl(1)); List <string> expectedDiscountsList = new List <string>(); expectedDiscountsList.Add(DiscountConstants.BOWL_DISCOUNT); Cart cart = CartHelper.CreateNotEmptyCart(list); var discountsList = cart.GetDiscount(); bool equalityCheckResult = expectedDiscountsList.Count == discountsList.Count; if (equalityCheckResult) { for (int i = 0; i < discountsList.Count; i++) { if (discountsList[i].Equals(expectedDiscountsList[i])) { continue; } else { equalityCheckResult = false; } } } Assert.IsTrue(equalityCheckResult); }
public void TestBagsShurikensDiscounts() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(100)); List <string> expectedDiscountsList = new List <string>(); expectedDiscountsList.Add(DiscountConstants.POGS_DISCOUNT); expectedDiscountsList.Add(DiscountConstants.SHURIKENS_DISCOUNT); Cart cart = CartHelper.CreateNotEmptyCart(list); var discountsList = cart.GetDiscount(); bool equalityCheckResult = expectedDiscountsList.Count == discountsList.Count; if (equalityCheckResult) { for (int i = 0; i < discountsList.Count; i++) { if (discountsList[i].Equals(expectedDiscountsList[i])) { continue; } else { equalityCheckResult = false; } } } Assert.IsTrue(equalityCheckResult); }
public void TestGetBasketSubtotal() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(15)); Cart cart = CartHelper.CreateNotEmptyCart(list); Assert.AreEqual(144.87M, cart.GetBasketSubtotal()); }
public void TestGetItemSubtotalNotExisting() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(15)); Cart cart = CartHelper.CreateNotEmptyCart(list); Assert.AreEqual(10.62M, cart.GetItemSubtotal(ProductConstants.LARGE_BOWL_ID)); }
public void TestGetProductCountExistingProduct() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(15)); Cart cart = CartHelper.CreateNotEmptyCart(list); Assert.AreEqual(2, cart.GetProductCount(ProductConstants.BAG_OF_POGS_ID)); }
public void TestGetGrandTotal() { List <CartItem> list = new List <CartItem>(); list.Add(CartItemHelper.AddBagOfPogs(2)); list.Add(CartItemHelper.AddShurikens(100)); list.Add(CartItemHelper.AddLargeBowl(1)); Cart cart = CartHelper.CreateNotEmptyCart(list); Assert.AreEqual(634.0005M, cart.GetGrandTotal()); }
public void TestEmptyCart() { List <CartItem> items = new List <CartItem>(); items.Add(CartItemHelper.AddPaperMask(4)); items.Add(CartItemHelper.AddLargeBowl(4)); Cart cart = CartHelper.CreateNotEmptyCart(items); cart.EmptyCart(); Assert.AreEqual(0, cart.ItemsList.Count); }
public void TestRemoveSet() { List <CartItem> items = new List <CartItem>(); items.Add(CartItemHelper.AddPaperMask(4)); Cart cart = CartHelper.CreateNotEmptyCart(items); cart.RemoveSet(CartItemHelper.AddPaperMask(1)); var existingItem = cart.ItemsList.FirstOrDefault(i => i.Id == ProductConstants.PAPER_MASK_ID); Assert.AreEqual(null, existingItem?.Quantity); }
public void TestNotEqualCarts() { List <CartItem> itemsListOriginal = new List <CartItem>(); itemsListOriginal.Add(CartItemHelper.AddShurikens(2)); itemsListOriginal.Add(CartItemHelper.AddLargeBowl(7)); itemsListOriginal.Add(CartItemHelper.AddPaperMask(3)); itemsListOriginal.Add(CartItemHelper.AddBagOfPogs(4)); List <CartItem> itemsListForComparison = new List <CartItem>(); itemsListForComparison.Add(CartItemHelper.AddShurikens(2)); itemsListForComparison.Add(CartItemHelper.AddPaperMask(1)); itemsListForComparison.Add(CartItemHelper.AddBagOfPogs(6)); Cart cartOriginal = CartHelper.CreateNotEmptyCart(itemsListOriginal); Cart cartForComparison = CartHelper.CreateNotEmptyCart(itemsListForComparison); Assert.IsFalse(cartOriginal.Equals(cartForComparison)); }