c# - 如何在 C# 中测试 COM 依赖对象

标签 c# tdd moq

我正在尝试对依赖于 COM 接口(interface)的对象执行 TDD。我想模拟 COM 接口(interface),同时进行开发测试,并在集成测试中真正做到这一点。

但是,我无法模拟 COM 接口(interface),我尝试使用 Moq,但它抛出异常:

System.TypeLoadException was unhandled by user code Message=Could not load type 'Castle.Proxies.iTunesAppProxy' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The type is marked as eligible for type equivalence, but either it has generic parameters, or it is not a structure, COM imported interface, enumeration, or delegate

其他框架可以吗? 如何使用 COM 依赖对象进行 TDD?

提前致谢!或委托(delegate)

最佳答案

尝试将包含 COM 接口(interface)的程序集的“嵌入互操作类型”设置为 FALSE。

关于c# - 如何在 C# 中测试 COM 依赖对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3223991/

相关文章:

c# - 如何禁用 Windows 8 中的纵向模式?

c# - 哪个更适合获得准确的性能计数 :DateTime or Stopwatch?

TDD模拟-是否指定模拟对象行为白盒测试?

ruby - 使用 Minitest 访问 Controller 实例变量

unit-testing - 为具有依赖性的对象模拟数据上下文

c# - MSTest - 带有列表参数的最小起订量设置返回空列表

c# - 调用 MonoTouch.UIKit.UIDevice.CurrentDevice.SystemVersion 时发生崩溃

c# - 什么是隐式泛型类型参数

.net - TDD 入门?

.net - 如何在 Moq 中调用作为参数传递的谓词?