我有单元测试,在其中我调用了一个最终调用这一行的方法:
DataSourceResult response = lstshiftGroup.ToDataSourceResult(request);
抛出异常:
Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
在我的测试项目中,我引用了 System.Web.Mvc,Version=4.0.0.0,在我的项目中,我有相同的程序集。
我的测试有什么问题?
最佳答案
您需要将对 Asp.Net MVC 的引用添加到您的单元测试项目中。您可以使用 NuGet 执行此操作。这是指向 MVC 的 NuGet 的链接。按照那里的说明将其安装到您的单元测试项目中:https://www.nuget.org/packages/aspnetmvc
关于c# - 无法在单元测试中加载文件或程序集“System.Web.Mvc”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24885159/