The Test Helpers are a great way to ease your testing needs with MVC. If your using the Test Helpers to test your routing like so:
"~/".ShouldMapTo<HomeController>(x => x.Index());
When you run your tests you’ll get the following error:
System.Security.VerificationException : Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument 'Your Controller Name’ violates the constraint of type parameter 'TController'.
The fix is a binding direct.
Add an app.config to your test project and paste in the following:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>
Happy Coding! Image may be NSFW.
Clik here to view.
Clik here to view.
