Dynamic Types Make Unit Testing JSON in ASP.NET MVC a Breeze!

added by jeffrymorris
10/19/2010 1:04:46 AM

0 Kicks, 127 Views

The new dynamic type in C# 4 was mainly added to offer simpler creation of objects using reflection and the ability to treat objects as they are no matter where they were created: COM interop, DLR, etc. It basically defers static typing until runtime. The object itself is statically typed, however the compiler bypasses compile-time static type checking until runtime. One place where this kind of late bound typing is really useful is unit testing ASP.NET MVC action methods that return JSON via JsonResult.