Exemple #1
0
        public void CartContoller_RemoveItem_Added()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(p => p.Products).Returns(new Product[] {
                new Product {ProductName="P1", ProductID=1},
                new Product {ProductName="P2", ProductID=2}
            }.AsQueryable());

            Cart cart = new Cart();
            CartController controller = new CartController(mock.Object, null);
            controller.AddItem(cart, 1, null);
            controller.AddItem(cart, 2, null);
            controller.RemoveItem(cart, 1, null);
            Assert.IsTrue(cart.Lines.Count() == 1);
        }