public void RedirectToBooksByGenre_CheckRedirectToBooksByGenre() { using (var homeController = new HomeController(MockData.MoqLogger(), MockData.MoqShopContext(), MockData.MoqEmailSender(), MockData.MoqMyLogger())) { var formCollection = new FormCollection(new Dictionary <string, StringValues>() { { "Genres", "1" } }); var controllerContext = new ControllerContext() { HttpContext = Mock.Of <HttpContext>(ctx => ctx.Request.Form == formCollection) }; homeController.ControllerContext = controllerContext; var action = homeController.RedirectToBooksByGenre() as RedirectToActionResult; // action.Should().Be("Home"); Assert.Equal("BooksByGenre", action.ActionName); Assert.Equal("Home", action.ControllerName); Assert.Equal("1", action.RouteValues["genreId"].ToString()); } }