以下是我的单元测试项目中的单元测试文件之一。 “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
以下是packages.config文件:
<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>
以下是app.config文件:
<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>
当我尝试调试此测试时,它给出了System.Security.VerificationException类型的异常 - Type参数违反了类型参数TController的约束。
知道为什么会这样吗?以及如何解决它?
答案 0 :(得分:0)
我在安装Visual Studio 2012的更新4后修复了它