Exemplo n.º 1
0
        public ActionResult LargeCart()
        {
            var items = _cartService.GetCartItems().ToList();
            var viewModel = new LargeCartViewModel
            {
                CartItems = items,
                Total = _cartService.ConvertToMoney(items.Sum(x => x.ExtendedPrice.Amount)),
                TotalDiscount = _cartService.GetTotalDiscount()
            };

            return PartialView("LargeCart", viewModel);
        }
Exemplo n.º 2
0
 public void LargeCart_WhenCreatingViewModel_ShouldCreateModel()
 {
     var expectedResult = new LargeCartViewModel
     {
         CartItems = new List<CartItem>
         {
             new CartItem
             {
                 Code = "code",
                 DiscountPrice = new Money(45, Currency.USD),
                 DisplayName = "red",
                 ExtendedPrice = new Money(270, Currency.USD),
                 PlacedPrice = new Money(50, Currency.USD),
                 Url = "url",
                 Quantity = 6
             }
         },
         Total = new Money(270, Currency.USD),
         TotalDiscount = new Money(30, Currency.USD)
     };
     var result = ((PartialViewResult)_subject.LargeCart()).Model as LargeCartViewModel;
     result.ShouldBeEquivalentTo(expectedResult);
 }