asp.net-mvcasp.net-mvc-4unit-testingmvccontrib

System.Security.VerificationException on unit test


Following is one of the unit test files in my Unit test project. "RouteConfigTests.cs"

[TestInitialize]
        public void Initialise()
        {
            RouteTable.Routes.Clear();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }

        #region default route
        [TestMethod]
        public void RouteDefault_ValidValues_ValidResultExpected()
        {
            "~/".ShouldMapTo<MessagesController>(x => x.Index());
        }
        #endregion

Following is the packages.config file:

<packages>
  <package id="AutoMapper" version="2.2.0" targetFramework="net45" />
  <package id="FakeItEasy" version="1.21.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="MicrosoftWebMvc" version="2.0" targetFramework="net45" />
  <package id="Mvc4Futures" version="4.0.20710.0" targetFramework="net45" />
  <package id="MvcContrib" version="2.0.95.0" targetFramework="net45" />
  <package id="MvcContrib.TestHelper" version="2.0.95.0" targetFramework="net45" />
  <package id="RhinoMocks" version="3.6" targetFramework="net45" />
</packages>

Following is the app.config file:

 <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

When I try to debug this test, it gives me exception of type System.Security.VerificationException - Type argument violates the constraint of type parameter TController.

Any idea of why this would be happening? and how to fix it?


Solution

  • I got it fixed after installing Updates 4 of Visual Studio 2012