# Thursday, 01 December 2011
« Finding where text/code is used in SQL S... | Main | SelfSSL on IIS 7 »

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:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="" newVersion="" />

Happy Coding! Smile

Wednesday, 06 June 2012 03:12:13 (US Mountain Standard Time, UTC-07:00)
Hi Hevin,
i had the same problem with TestHelpers of MVC Contrib.
Your tip helps me a lot :-)

Nice job. Thanks!

Monday, 11 June 2012 21:36:10 (US Mountain Standard Time, UTC-07:00)
Glad to help another out!
Thursday, 13 September 2012 15:17:53 (US Mountain Standard Time, UTC-07:00)
Thanks! Helped me too!
Tuesday, 02 October 2012 11:24:31 (US Mountain Standard Time, UTC-07:00)
i have the same problem but this walkarround did not work. I am using mvc4 (non beta) with visual studio 2012.

thanks a ton!
Tuesday, 02 October 2012 12:20:13 (US Mountain Standard Time, UTC-07:00)
I just recently upgraded to VS 2012 and had the exact results. I couldn't get my existing or brand new apps to work with the binding. While I know of others that are working with the binding I couldn't on my PC or laptop. The fix for me in this case was to download the source and rebuild the testhelpers library against the new MVC4 dll and then reference the new test helpers dll in my MVC4, VS 2012 project.
Tuesday, 02 October 2012 12:44:12 (US Mountain Standard Time, UTC-07:00)
thanks kevin for your quick reply. I will try that
Tuesday, 02 October 2012 23:24:45 (US Mountain Standard Time, UTC-07:00)

Just a comment. There was a missing file "ReflectionHelper". I walkarrounded all the dependencies and the final dll works for my needs, but It's a shame not having the full functionality. If you have a chance to add that file, would be nice.

Thanks a ton!
Please login with either your OpenID above, or your details below.
(will show your gravatar icon)
Home page

Comment (Some html is allowed: b, blockquote@cite, em, i, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview