Beispiel #1
0
        public void canAddBasketItems()
        {
            //setup
            IRepository <Basket>   basket    = new MockContext <Basket>();
            IRepository <Product>  product   = new MockContext <Product>();
            IRepository <Order>    orders    = new MockContext <Order>();
            IRepository <Customer> customers = new MockContext <Customer>();

            var httpcontext = new MockHttpContext();

            IBasketService basketService = new BasketService(product, basket);
            IOrderService  orderService  = new OrderService(orders);
            var            controller    = new BasketController(basketService, orderService, customers);

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

            //Act
            //basketService.addToBasket(httpcontext, "1");
            controller.addToBasket("1");

            Basket bas = basket.collection().FirstOrDefault();

            //Assert
            Assert.IsNotNull(bas);
            Assert.AreEqual(1, bas.basketItems.Count);
            Assert.AreEqual("1", bas.basketItems.ToList().FirstOrDefault().productId);
        }