public void CanAddProductToCart() { var mockProductRepository = UnitTestHelpers.MockProductsRepository( new Product { ProductID = 123 }, new Product { ProductID = 456 } ); var cartController = new CartController(mockProductRepository, null); var cart = new Cart(); cartController.AddToCart(cart, 456, null); cart.Lines.Count.ShouldEqual(1); cart.Lines[0].Product.ProductID.ShouldEqual(456); }
public void AfterAddingProductToCartUserGoesToYourCartScreen() { var mockProductsRepository = UnitTestHelpers.MockProductsRepository( new Product { ProductID = 1 } ); var cartController = new CartController(mockProductsRepository, null); // Act: When a user adds a product to their cart... var result = cartController.AddToCart(new Cart(), 1, "someReturnUrl"); // Assert: Then the user is redirected to the Cart Index screen result.ShouldBeRedirectionTo(new { action = "Index", returnUrl = "someReturnUrl" }); }