public UnitTestShoppingCart() { CartItem c1 = new CartItem(1); c1.Product = new Product(1, "P1"); c1.Product.ProductPrice = 25; c1.Product.ProductDiscount = 20; c1.Quantity = 1; CartItem c2 = new CartItem(1); c2.Product = new Product(2, "P2"); c2.Product.ProductPrice = 25; c2.Product.ProductDiscount = 24; c2.Quantity = 2; CartItem c3 = new CartItem(1); c3.Product = new Product(3, "P2"); c3.Product.ProductPrice = 25; c3.Product.ProductDiscount = 30; c3.Quantity = 1; cart.AddItemToCart(c1); cart.AddItemToCart(c2); cart.AddItemToCart(c3); }
public void AddExistingItem() { _shoppingCart.Items = AddItems(2, 3, 5); var currentItems = _shoppingCart.Items.Count; _shoppingCart.AddItemToCart(AddOneItem(1)); Assert.AreEqual(_shoppingCart.Items.Count, currentItems); }
public RedirectToActionResult AddToShoppingCart(int VinNo) { var selectedVehicle = _vehicleRepository.GetVehicleByVinNo(VinNo); _shoppingCart.AddItemToCart(selectedVehicle, selectedVehicle.Amount); return(RedirectToAction("Index")); }
public RedirectToActionResult AddToShoppingCart(int productId) { var selectedProduct = productRepository.GetProductById(productId); shoppingCart.AddItemToCart(selectedProduct, selectedProduct.Price); return(RedirectToAction("Index")); }
public void AddItemToCartTest() { var storeShelf = new StoreShelf(); var shoppingCart = new ShoppingCart(); shoppingCart.AddItemToCart(storeShelf.SearchAndRetrieveItemFromShelf("book", 12.49M, false, 1)); Assert.IsNotNull(shoppingCart.GetItemsFromCart()); }
public RedirectToActionResult AddToShoppingCart(int courseId) { var SelectedCourse = courseRepository.GetCourseById(courseId); shoppingCart.AddItemToCart(SelectedCourse, SelectedCourse.Fee); return(RedirectToAction("Index")); }
public RedirectToActionResult AddToShoppingCart(int bookId) { var selectedBook = bookRepository.GetBookById(bookId); shoppingCart.AddItemToCart(selectedBook, selectedBook.Price); return(RedirectToAction("Index")); }
static void Main(string[] args) { ShoppingCart _cart = null; /*Check that there are products added * in the command line arguments*/ if (args.Length > 0) { _cart = new ShoppingCart(); //check each item in the command line arguments is a valid product foreach (string sItem in args) { Product anItem = TheStore.AvailableProducts.ToList().Find (ap => ap.DescriptionName.Equals(sItem.ToLower())); if (anItem != null) { _cart.AddItemToCart(anItem); } else { Console.WriteLine("\n***************************************"); Console.WriteLine("\tPLEASE ENTER A VALID ITEM"); Console.WriteLine("***************************************"); Console.WriteLine("{0} is not a valid item", sItem); Console.WriteLine("Valid items include: Apples, Bread, Milk, Soup"); break; } } //Produce an invoice for the item(s) ShoppingInvoice si = _cart.ProcessCart(); Console.WriteLine("\n***************************************"); Console.WriteLine("SubTotal: " + si.Subtotal.ToString("C")); foreach (string s in si.DiscountMessages) { Console.WriteLine(s); } Console.WriteLine("Total: " + si.Total.ToString("C")); Console.WriteLine("***************************************"); //Console.WriteLine(_cart.CartItems[0].DiscountAmount); } //User did not enter any products on the command line else { Console.WriteLine("Please list some items to add"); Console.WriteLine("Valid items include: Apples, Bread, Milk, Soup"); Console.WriteLine(args.Length); } }
public void TestCase1_CalculateSalesTax() { Product p1 = storeShelf.SearchAndRetrieveItemFromShelf("book", 12.49, false, 1); Product p2 = storeShelf.SearchAndRetrieveItemFromShelf("music cd", 14.99, false, 1); Product p3 = storeShelf.SearchAndRetrieveItemFromShelf("box of chocolates", 0.85, false, 1); shoppingCartObj.AddItemToCart(p1); shoppingCartObj.AddItemToCart(p2); shoppingCartObj.AddItemToCart(p3); List <Product> productList = shoppingCartObj.GetItemsFromCart(); biller.CalcSalesTax(productList); double totalTax = biller.CalcTotalTax(productList); double totalAmount = biller.CalcTotalAmount(productList); Assert.AreEqual(1.50d, totalTax); Assert.AreEqual(29.83d, totalAmount); }
public IActionResult CheckOut(bool clear) { if (clear) { dataHandler.ClearCart(); } var productAtCart = dataHandler.GetCartProducts(); foreach (var product in productAtCart) { shoppingCart.AddItemToCart(product); } ViewBag.CartSize = shoppingCart.GetCartSize(); return(View(shoppingCart)); }