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

前端 未结 3 1930
抹茶落季
抹茶落季 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:15

    Please note that

    Assert.IsInstanceOfType(result,typeof(RedirectToRouteResult)); 
    

    has been deprecated.

    The new syntax is

    Assert.That(result, Is.InstanceOf());
    

提交回复
热议问题