public void ShoppingCartUpdate_CheckRedirection(int id, int value) { using (var homeController = new HomeController(MockData.MoqLogger(), MockData.MoqShopContext(), MockData.MoqEmailSender(), MockData.MoqMyLogger())) { OrderedBook orderedBook1 = new OrderedBook { BookId = 1, Quantity = 3 }; OrderedBook orderedBook2 = new OrderedBook { BookId = 2, Quantity = 4 }; OrderedBook orderedBook3 = new OrderedBook { BookId = 4, Quantity = 2 }; OrderedBook orderedBook4 = new OrderedBook { BookId = 3, Quantity = 3 }; List <OrderedBook> mockOrderedBookList = new List <OrderedBook>(); mockOrderedBookList.Add(orderedBook1); mockOrderedBookList.Add(orderedBook2); mockOrderedBookList.Add(orderedBook3); mockOrderedBookList.Add(orderedBook4); var controllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { Session = new MockHttpSession() } }; homeController.ControllerContext = controllerContext; homeController.HttpContext.Session.Set(WebConst.SessionCart, mockOrderedBookList); var action = homeController.ShoppingCartUpdate(id, value) as RedirectToActionResult; Assert.Equal("ShoppingCart", action.ActionName); } }