public void StoreController_AddItem_ValidateAddsItem() { var item = new StoreItem("Tomato Sauce", .89m); var okResponse = _controller.Post(item); Assert.Equal(6, _store.GetAllItems().Count()); }
public void MultiplesPromotionController_AddItem_ValidateAddsItem() { var item = new MultiplesPromotion("Bread", 2, 3.00m); var okResponse = _controller.Post(item); Assert.Equal(3, _multiples.GetAllItems().Count()); }
public void MarkdownPromotionController_AddItem_ValidateAddsItem() { var item = new MarkdownPromotion("Steak", -.50m); var okResponse = _controller.Post(item); Assert.Equal(2, _markdowns.GetAllItems().Count()); }
public void BogoPromotionController_AddItem_ValidateAddsItem() { var item = new BogoPromotion("Chorizo", 2, 1, 50, 3); var okResponse = _controller.Post(item); Assert.Equal(2, _bogos.GetAllItems().Count()); }
public void CartController_GetCartTotal_ReturnsBadResponse() { //clear out cart _cart.GetAllItems().ToList().ForEach(x => _cart.Remove(x)); var badResponse = _controller.GetCartTotal(); Assert.IsType <BadRequestObjectResult>(badResponse.Result); }
public void Cart_TestMultiplesPromotion_Remainder() { Cart cart = new Cart(); cart.AddPricedItems(_cart.GetAllItems(), _store.GetAllItems()); cart.ApplyPromotions(null, _multiples.GetAllItems(), null); Assert.Equal(31.5625m, cart.Total); }
public void Cart_TestMarkdownPromotion_ValidPromotion() { Cart cart = new Cart(); cart.AddPricedItems(_cart.GetAllItems(), _store.GetAllItems()); cart.ApplyPromotions(_markdowns.GetAllItems(), null, null); Assert.Equal(32.3625m, cart.Total); }
public ActionResult <Cart> GetCartTotal() { Cart cart = new Cart(); //add items to cart with price cart.AddPricedItems(_cart.GetAllItems(), _store.GetAllItems()); //if cart is empty bad request if (cart.Total == 0 || _cart.GetAllItems().Count() == 0) { return(BadRequest("Cart is empty.")); } //add promotional line items after adding items to cart with price cart.ApplyPromotions(_markdowns?.GetAllItems(), _multiples?.GetAllItems(), _bogos?.GetAllItems()); return(Ok(cart)); }
public ActionResult <List <BogoPromotion> > Get() { List <BogoPromotion> items = _bogos.GetAllItems(); return(Ok(items)); }
public void Cart_TestProperties() { Cart cart = new Cart(); cart.AddPricedItems(_cart.GetAllItems(), _store.GetAllItems()); Assert.Equal(32.5625m, cart.Total); }
public ActionResult <List <StoreItem> > Get() { List <StoreItem> items = _store.GetAllItems(); return(Ok(items)); }
public ActionResult <List <CartItem> > Get() { List <CartItem> items = _cart.GetAllItems(); return(Ok(items)); }
public ActionResult <List <MultiplesPromotion> > Get() { List <MultiplesPromotion> items = _multiples.GetAllItems(); return(Ok(items)); }
public ActionResult <List <MarkdownPromotion> > Get() { List <MarkdownPromotion> items = _markdowns.GetAllItems(); return(Ok(items)); }