public JsonResult GetPayments()
{
var paymentTypes = PaymentRepository.GetAll();
var jsonData = new { rows = paymentTypes.Select(q => new { Id = q.Id.ToString(), q.Name }).ToList() };
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
It basically returns the Id and Name of the Payments as Json data.
I was wanting to test this so I was wanting to test that each row of data generated had the right information in it.
However the JsonResult returned I can do:
JsonResult.Data
I can’t seem to get to the individual rows. Any suggestions?
I asked a similar question a few months ago.
As the accepted answer states, i ended up using a simple reflection-based test helper to check the properties.
The alternative (answered after i accepted the original answer) is to make the internals of the web project visible to your tests project.