How can you test that an action method you have like so will return the correct view because Viewname is an empty string? Should I even bother testing this? I’m not sure how many unit tests to do, I’m thinking you could create a lot of unit tests!
public ActionResult Index()
{
return View();
}
[TestMethod]
public void DetermineIndexReturnsCorrectView()
{
HomeController controller = new HomeController();
ViewResult result = controller.Index() as ViewResult;
//****result.ViewName is empty!!!!***//
Assert.AreEqual("Index", result.ViewName);
}
Take a look at MvcContrib Testhelpers. Nice examples there as well