Unit testing my controller method results in an empty ViewName?

后端 未结 4 876
情歌与酒
情歌与酒 2020-12-29 21:18

I\'m doing some simple MS unit tests on my standard, nothing special controller.

When I check the ViewName proprty, from the returned ViewResult

4条回答
  •  有刺的猬
    2020-12-29 22:09

    The viewname is set automatically by the framework. But when we unit test, we short-circuit the framework and there is nothing left to set the name.

    So our actions need to set the viewname explicitly when we unit test. We could also check for null or empty if we really, really want to lean on the convention.

提交回复
热议问题