Esempio n. 1
0
        public void CanAddBasketItem()
        {
            IRepository <Basket>  baskets  = new MockContext <Basket>();
            IRepository <Product> products = new MockContext <Product>();

            var httpContext = new MockHttpContext();

            IBasketService basketService = new BasketService(products, baskets);
            var            controller    = new BasketController(basketService);

            controller.ControllerContext = new System.Web.Mvc.ControllerContext(httpContext, new System.Web.Routing.RouteData(), controller);

            //basketService.AddToBasket(httpContext, "1");
            controller.AddTobasket("1");

            Basket basket = baskets.Collection().FirstOrDefault();

            Assert.IsNotNull(basket);
            Assert.AreEqual(1, basket.Basketitems.Count);
            Assert.AreEqual("1", basket.Basketitems.ToList().FirstOrDefault().ProductId);
        }