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?
My Guess is that you're using the MVCContrib for MVC2, and it uses the MVC2 ViewResult. Whereas, you're returning an MVC3 ViewResult.
Have you tried compiling MVCContrib against MVC3?