【发布时间】:2016-08-07 02:51:52
【问题描述】:
我正在尝试为 MVC 应用程序编写一些集成测试,如下所示
控制器
public JsonResult CreateWithJson(List<string> values)
{
if (values == null) return Json(new { Valid = false, Message = "No data was received by the server" });
}
测试类
public static void TestEmptyDataFailsGracefully()
{
var objUt = new MyController();
var actual = objUt.CreateWithJson(new List<string>());
actual.Should().BeOfType(typeof(JsonResult));
// this is System.Object
actual.Data...
// what I want to do
actual.Data.Valid.Should.Be(false);
}
请问JsonResult中返回的匿名类型如何查询呢?
【问题讨论】:
标签: c# asp.net-mvc anonymous-types