How to unit-test an action, when return type is ActionResult?
问题 I have written unit test for following action. [HttpPost] public ActionResult/*ViewResult*/ Create(MyViewModel vm) { if (ModelState.IsValid) { //Do something... return RedirectToAction("Index"); } return View(vm); } Test method can access Model properties, only when return type is ViewResult . In above code, I have used RedirectToAction so return type of this action can not be ViewResult . In such scenario how do you unit-test an action? 回答1: So here is my little example: public ActionResult