A: 

If you want to test template you have to execute ExecuteResult of the ViewResult. The problem is ControllerContext that you have to pass to this method. You have to mock too many stuff. You can look for test helpers in MvcContrib. They prebuilt some mocks.

On the other hand, probably this is not good idea. In most cases it’s better to cover such stuff with integration tests. Even simple request to the url will give confidence that template is successfully compiled.

Mike Chaliy
How would I go about integration testing something like this?
devlife
We use Visual Studio Web Tests. There are bunch of other options.
Mike Chaliy
A: 

Another option would be to explicitly name the ActionResult returned by your controller and then test based on that..

public ActionResult Index()
{
   return View("Index");
}

and

UsersController controller = new UsersController( );
ViewResult result = controller.Index( ) as ViewResult;
Assert.IsNotNull( result );
Assert.AreEqual("Index", result.ViewName);

If you've got alot of redirections going on in your controller, or if your controller method could return different views this can be useful. (Generally there shouldn't be much logic in your controller, but sometimes it's just necessary/easier to work that way..)

Peter Bernier
Thanks Peter I'll give that a try.
devlife