I am trying to use the MvcContrib Test Helper to test a controller method in MVC3.
The controller:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
The test:
[TestMethod]
public void Index()
{
// Arrange
HomeController controller = new HomeController();
// Act
ViewResult result = controller.Index() as ViewResult;
// Assert
result.AssertViewRendered().ForView("Index");
}
The error:
Test method Tests.Web.Controllers.HomeControllerTests.Index threw exception: MvcContrib.TestHelper.ActionResultAssertionException: Expected result to be of type ViewResult. It is actually of type ViewResult.
Any ideas?