public void ShouldDeleteCartRecordAndUpdateTotalNumberOfItems() { var item = _cartLineRepo.Find(1); _cartLineRepo.Context.Entry(item).State = EntityState.Detached; _cartLineRepo.Delete(item); Context.OrderId = 1; var shoppingCartRecords = _cartLineRepo.GetCartLinesByOrder(Context.OrderId).ToList(); _orderRepo.GetTotalPriceAndPersist(Context.OrderId, shoppingCartRecords); var cartLines = _cartLineRepo.GetAll(x => x.Id).ToList(); Assert.Equal(2, cartLines[0].Id); var order = _orderRepo.GetOrder(Context.OrderId); Assert.Equal(825M, order.Total); }
[ProducesResponseType(500)] //Returned when there was an error in the repo public ActionResult <CartLine> GetCartLine(long id) { CartLine cartLine = _repo.Find(id); return(cartLine ?? (ActionResult <CartLine>)NotFound()); }