public void Adding_Product_To_Cart_Goes_To_Cart_Screen() { // Arrange var cart = new Cart(); var cartController = new CartController(mock.Object, null); // Act RedirectToRouteResult result = cartController.AddToCart(cart, 2, "myUrl"); // Assert Assert.AreEqual(result.RouteValues["action"], "Index"); Assert.AreEqual(result.RouteValues["returnUrl"], "myUrl"); }
public void Can_Add_To_Cart() { // Arrange var cart = new Cart(); var cartController = new CartController(mock.Object, null); // Act cartController.AddToCart(cart, 1, null); // Assert Assert.AreEqual(cart.Lines.Count(), 1); Assert.AreEqual(cart.Lines.ToArray()[0].Product.ProductId, 1); }