public void TestWithOfferAppliedFailed(long appleCount, long bananaCount, long peachCount) { for (int i = 1; i <= appleCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(1, shoppingCart); } for (int i = 1; i <= bananaCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(2, shoppingCart); } for (int i = 1; i <= peachCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(3, shoppingCart); } Bill invoice = CheckoutKataHelper.GenerateBill(shoppingCart.cart, offer, pricePerItem); // Apple - 2 (45) + 1 (30) = 75 // Banan - 3 (130) + 1 (50) = 180 // peach - 1 (60) = 60 Assert.AreNotEqual(100, invoice.PayableAmount()); }
public void TestWithoutAnyOffer(long appleCount, long bananaCount, long peachCount) { for (int i = 1; i <= appleCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(1, shoppingCart); } for (int i = 1; i <= bananaCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(2, shoppingCart); } for (int i = 1; i <= peachCount; i++) { shoppingCart = CheckoutKataHelper.AddItemInShoppingCart(3, shoppingCart); } Bill invoice = CheckoutKataHelper.GenerateBill(shoppingCart.cart, offer, pricePerItem); // Apple - 1 (30) = 30 // Banan - 2 (50) = 100 // peach - 3 (60) = 180 Assert.AreEqual(310, invoice.PayableAmount()); }
static void Main(string[] args) { ShoppingCart shoppingBucket = new ShoppingCart(); //Weekly Offer WeeklyOffer offer = new WeeklyOffer(); offer.Offer.Add(Products.Apple, new Dictionary <long, double> { { 2, 45 } }); offer.Offer.Add(Products.Banana, new Dictionary <long, double> { { 3, 130 } }); //Product Price PricePerItem pricePerItem = new PricePerItem(); pricePerItem.PricePerProduct.Add(Products.Apple, 30); pricePerItem.PricePerProduct.Add(Products.Banana, 50); pricePerItem.PricePerProduct.Add(Products.Peach, 60); Console.WriteLine("\n\n"); Console.WriteLine("====================================="); Console.WriteLine("Shopping Cart Kata"); Console.WriteLine("====================================="); Console.WriteLine("\n\n"); double value = 0; string inputMessage = CheckoutKataHelper.GenerateInputMessage(); do { Console.Write(inputMessage); value = CheckoutKataHelper.ValidateInput(); if (value != 0) { shoppingBucket = CheckoutKataHelper.AddItemInShoppingCart(value, shoppingBucket); } } while (value != 0); //Add in the bill Bill custBill = CheckoutKataHelper.GenerateBill(shoppingBucket.cart, offer, pricePerItem); //Print bill. CheckoutKataHelper.PrintBill(custBill, offer, pricePerItem); }