I cannot seem to return the result.ViewName for use in Nunit tests as it always returns string.empty. I have explicitly set the name of the view inside my controller and would expect the test to pick this up. I have had a hunt around and it seems that I should get the Viewname back if I set it explicitly. Any one got any ideas?
public class HomeController : Controller
{
public ActionResult Index()
{
return View("Index");
}
}
My test looks like this
[Test]
public void TestIndexView()
{
var controller = new HomeController();
var result = controller.Index() as ViewResult;
Assert.AreEqual("Index", result.ViewName);
}