public void BuyProductTest() { // Arrange AppController appController = this.CreateAppController(); appController.ControllerContext = new ControllerContext(); appController.ControllerContext.HttpContext = new DefaultHttpContext(); appController.ControllerContext.HttpContext.Session = new MockHttpSession(); var oneProduct = ProductsDummy.GetProducts().FirstOrDefault(); // Act appController.Index(); appController.InfoProduct(oneProduct.Id.ToString()); appController.AddToCart(oneProduct.Id.ToString()); this.mockSimpleStoreRepository .Setup(r => r.BuyNow(It.IsAny <Cart>(), It.IsAny <string>())) .Returns(new Cart() { SuccessPayment = true }); var viewActionBuy = appController.BuyNow() as ViewResult; // Assert var model = viewActionBuy.Model as Cart; Assert.IsTrue(model.SuccessPayment); }