3

我在其中一个单元测试项目(VS 2010 单元测试)中使用 Microsoft Moles Framework (x86) 版本 0.94.51023.0。为了测试应用程序中的数据访问层方法,我尝试为System.Data.dll添加 moles 程序集,以便可以模拟SqlConnection&SqlCommand对象。当我在添加 moles 程序集时构建单元测试时,构建失败并出现以下错误详细信息

error CS0234: The type or namespace name 'SqlCredential' does not exist in the namespace 'System.Data.SqlClient'

error CS0234: The type or namespace name 'ApplicationIntent' does not exist in the namespace 'System.Data.SqlClient'

我的构建输出窗口的结尾显示了这个:

error MSB3073: The command ""C:\Program Files (x86)\Microsoft Moles\bin\moles.exe" @...\UnitTests\obj\Debug\Moles\moles.args" exited with code -1002.
4

2 回答 2

1

将“ C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 ”中的“ System.Data dll ”替换为“4.0.30319.17929”版本后,该问题似乎已解决“ C:\Windows\Microsoft.NET\Framework64\v4.0.30319 ”。看起来这个版本的 dll 中定义了 SqlCredential 类型,我能够成功地破坏 System.Data dll

于 2013-03-08T05:18:14.703 回答
0

我遇到了这篇文章http://feherzsolt.wordpress.com/2013/02/13/moles-and-net-4-5/,它似乎有解决Moles无法为系统生成moled组件的问题的正确解决方案.* dll。当 .Net f/w 4.0 和 4.5 安装在同一台机器上时,对于使用 4.0 dll 的项目,在 moles 文件中添加 ReflectionOnly="true" 属性,可以解决构建失败问题。

于 2013-12-02T12:48:14.757 回答