public async Task ViewShoppingCart_Success()
        {
            //Arrange
            mockSession();


            VMActivityCart cartOtpt = new VMActivityCart()
            {
                CartId   = 1,
                CartItem = new List <ActivityCartDTO>()
                {
                    new ActivityCartDTO()
                    {
                        ActivityID          = 1,
                        ActivityImage       = "test//test",
                        ActivityDescription = "test",
                        ActivityName        = "test",
                        ActivityFee         = 50,
                        Quantity            = 1
                    }
                }
            };

            _shopping.Setup(x => x.FetchShoppingCart(It.IsAny <string>())).Returns(Task.FromResult(cartOtpt));

            //Act
            var result = await controller.ViewShoppingCart() as ViewResult;

            //Assert
            Assert.NotNull(result.Model);
        }
Ejemplo n.º 2
0
        public async Task <VMActivityCart> FetchShoppingCart(string userEmail = null)
        {
            var result = await _dbContext.ActivityCart.AsNoTracking().Where(x => x.Username == userEmail)
                         .Select(x => new { cartItems = JsonConvert.DeserializeObject <List <ActivityCartDTO> >(x.ItemDetails), cartId = x.Id }).FirstOrDefaultAsync();

            VMActivityCart cart = new VMActivityCart
            {
                CartId   = result.cartId,
                CartItem = result.cartItems
            };

            return(cart);
        }