I'm trying to write some integration tests for an MVC application as follows
Controller
public JsonResult CreateWithJson(List<string> values)
{
if (values == null) return Json(new { Valid = false, Message = "No data was received by the server" });
}
Test Class
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);
}
So how do I query the anonymous type returned in the JsonResult please ?