How do I make a unit test for my Index ActionResult to test the view result?
如何为Index ActionResult进行单元测试以测试视图结果?
public ActionResult Index()
{
if (!new SessionStateCredentialStore().HasAllCredentials())
return RedirectToAction("Index", "OAuth");
return View("Index");
}
1 个解决方案
#1
0
That's how your unit test condition should looks:
这就是你的单元测试条件应该如何:
var result = controller.Index();
RedirectToRouteResult routeResult = result as RedirectToRouteResult;
Assert.AreEqual(routeResult.RouteValues["Index"], "OAuth");
#1
0
That's how your unit test condition should looks:
这就是你的单元测试条件应该如何:
var result = controller.Index();
RedirectToRouteResult routeResult = result as RedirectToRouteResult;
Assert.AreEqual(routeResult.RouteValues["Index"], "OAuth");