Exemplo n.º 1
0
        public void adding_product_redirects_to_index()
        {
            // arrange
            IProductsRepository repository = Substitute.For<IProductsRepository>();
            repository.Products.Returns(new List<Product> { new Product { ProductID = 123 } }.AsQueryable());
            CartController controller = new CartController(repository, null);

            // act
            var result = controller.AddProduct(123, null, new Cart());

            // assert
            result.ShouldBeRedirectionTo(new { action = "Index" });
        }
Exemplo n.º 2
0
        public void can_add_products_to_cart()
        {
            // arrange
            IProductsRepository repository = Substitute.For<IProductsRepository>();
            Product someProduct = new Product { ProductID= 123 };
            repository.Products.Returns( new List<Product> { someProduct }.AsQueryable() );
            Cart cart = new Cart();

            CartController controller = new CartController(repository, null);

            // act
            controller.AddProduct(123, null, cart);

            // assert
            cart.Lines[0].Product.ShouldEqual(someProduct);
        }