我希望编写一个单元测试,以确保我返回的视图是正确的。
我的计划是编写一个测试,首先调用控制器,然后调用我打算测试的ActionResult方法。 我想我可以编写类似以下的内容:
Controller controller = new HomeController();
var actionresult = controller.Index();
Assert.False(actionresult.ToString(), String.Empty);
这将允许我解析Action结果以获取测试值。
但是,我无法直接实例化public ActionResult Index()
方法。
我该怎么做?