I have an action that returns a json array of anonymous objects:
public JsonResult GetItems()
{
var items = new[] { new { Id = 1, Name = "One" }, new { Id = 2, Name = "Two" } };
return Json(items);
}
How do I write a test for that method? Something like this:
[TestMethod]
public void MyController_GetItems()
{
var controller = new MyController();
var result = controller.GetItems();
dynamic items = result.Data;
Assert.AreEqual("One", items[0].Name); // ???
}