就像this guy,我在創建MVC 4項目時沒有創建單元測試項目。現在我想回去添加一個。將單元測試項目添加到ASP.Net MVC 4項目
爲此,我創建了一個新的單元測試項目。爲什麼單位
Unit Test Generation Error: The following error was encountered while reading module 'My.Project': Could not resolve the type reference: [System.Web.Mvc, Version 3.0.0.0, Culture=neutral, PublicKeyToken={why doesn't MS support cut and paste??}]System.Web.Mvc.AllowAnonymousAttribute.
AllowAnonymousAttribute是新的MVC 4:
現在,我在一個私人的方法在我的控制器之一單擊鼠標右鍵,選擇創建單元測試,並得到一個彈出式對話框的認定儘管測試生成器試圖解決MVC 3程序集?
My.Project編譯並運行得很好,AllowAnonymousAttribute和all,顯然是尊重System.Web.Mvc,版本4.0.0.0。
UPDATE
MyMvc.csproj包含
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
在HintPath的DLL被證實爲版本4.0.0.0
MyMvc.Test.csproj包含
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
這並沒有解決問題。 –