public void BooksByPublisherPost_CheckRedirectionAndSession(int id, int quantity, int pId) { using (var homeController = new HomeController(MockData.MoqLogger(), MockData.MoqShopContext(), MockData.MoqEmailSender(), MockData.MoqMyLogger())) { var formCollection = new FormCollection(new Dictionary <string, StringValues>() { { "Publishers", pId.ToString() } }); var controllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext { Session = new MockHttpSession(), Request = { Form = formCollection } }, }; homeController.ControllerContext = controllerContext; var action = homeController.BooksByPublisherPost(id, quantity, pId) as RedirectToActionResult; Assert.Equal("BooksByPublisher", action.ActionName); Assert.Equal(pId.ToString(), action.RouteValues["publisherId"].ToString()); } }