Asserting JsonResult Containing Anonymous Type

前端 未结 3 462
广开言路
广开言路 2021-02-05 00:51

I was trying to unit test a method in one of my Controllers returning a JsonResult. To my surprise the following code didn\'t work:

[HttpPost]
public JsonResult          


        
3条回答
  •  名媛妹妹
    2021-02-05 01:42

    Anonymous types are internal, so you can't expose them to another library, the one with tests. If you placed testing code in the same library as controller, it will work.

提交回复
热议问题