相关疑难解决方法(0)

安装.NET 4.5后,以前的Unit-Test项目无法构建

我有一个.NET 4.0 WPF解决方案,其中包含一个单元测试项目,用于测试视图模型中使用的不同命令.一切都很好.然后我安装了.NET framework 4.5然后安装了VS2012,并开始收到如下错误消息 -

XYZProject.UsersViewModel_Accessor.AddUserToAccountsCommand' is not supported by the language

在安装VS2012之前UnitTestFramework.dll,引用了 -

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\

被改为引用 -

C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0

所以它从VS2012中获取了引用,我手动恢复了该引用.但没有运气.

AddUserToAccountsCommand是一个ICommand驻留在PresentationCore.dll.NET 4.0中的对象,但是System.dll在.NET 4.5中.所以我也检查了这些参考文献,它们似乎就像以前一样.

错误消息仅显示创建测试目标的位置,如Access,例如UsersViewModel_Accessor,表示以下代码生成错误 -

UsersViewModel_Accessor target = new UsersViewModel_Accessor();
Assert.IsTrue(target.AddUserToAccountsCommand.CanExecute(null), "Failed to perform can exetuce of add user command");
target.AddUserToAccountsCommand.Execute(null);  
Run Code Online (Sandbox Code Playgroud)

但如果使用viewmodel类型直接创建测试目标,如下所示 -

UsersViewModel target = new UsersViewModel();
Assert.IsTrue(target.AddUserToAccountsCommand.CanExecute(null), "Failed to perform can exetuce of add user command");
target.AddUserToAccountsCommand.Execute(null);  
Run Code Online (Sandbox Code Playgroud)

没有错误发生,项目构建成功.那么,有人可以分享任何想法吗? …

wpf .net-4.0 icommand vs-unit-testing-framework .net-4.5

19
推荐指数
1
解决办法
1739
查看次数