RPM,您看起来是正确的。我还有很多要学习的知识
dynamic,我也无法获得Marc的工作方法。所以这是我以前的做法。您可能会发现它很有帮助。我只是写了一个简单的扩展方法:
public static object GetReflectedProperty(this object obj, string propertyName) { obj.ThrowIfNull("obj"); propertyName.ThrowIfNull("propertyName"); PropertyInfo property = obj.GetType().GetProperty(propertyName); if (property == null) { return null; } return property.GetValue(obj, null); }然后,我只是使用它对我的Json数据进行断言:
JsonResult result = controller.MyAction(...); ... Assert.That(result.Data, Is.Not.Null, "There should be some data for the JsonResult"); Assert.That(result.Data.GetReflectedProperty("page"), Is.EqualTo(page));


