我正在测试控制器是否没有参数,它应该重定向到action "Index"
。
// Controller code
return RedirectToAction("Index");
// Unit test code
ActionResult result = Controller.Action(null);
Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
Assert. // HERE i need to test it is going to Index, how do I do that?
您需要像这样查看RouteValues词典:
Assert.AreEqual("Index", (result as RedirectToRouteResult).RouteValues["action"]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句