How to unit-test an action, when return type is ActionResult?

前端 未结 3 1929
抹茶落季
抹茶落季 2020-12-05 09:44

I have written unit test for following action.

[HttpPost]
public ActionResult/*ViewResult*/ Create(MyViewModel vm)
{
    if (ModelState.IsValid)
    {
               


        
3条回答
  •  离开以前
    2020-12-05 10:12

    Try this code:

    dynamic result=objectController.Index();
    Assert.AreEqual("Index",result.ViewName);
    

提交回复
热议问题