问题描述
这可能会或可能不会是一个多接口的问题,但我做这样的事情:
This may or may not be a multi-interface problem, but I'm doing something like this:
var mockInterface1 = new Mock<IInterface1>();
var mockInterface2 = mockInterface1.As<IInterface2>();
mockInterface1.Expect( foo => foo.Foo(It.IsAny<IInterface3>() ) );
...
otherObject.DoSomething( (IInterface1)mockInterface2.Object );
在运行时的DoSomething的行我得到:
On the DoSomething line at runtime I get:
MyTest的(TestFixtureSetUp):System.Reflection.TargetInvocationException:异常被抛出调用的目标
MyTest (TestFixtureSetUp):System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.TypeInitializationException:的类型初始IInterface1Proxy184f83d417624e05b450fa40c2c5d35c'引发了异常
----> System.TypeInitializationException : The type initializer for 'IInterface1Proxy184f83d417624e05b450fa40c2c5d35c' threw an exception.
----> System.BadImageFormatException:试图用不正确的格式加载程序。 (从HRESULT异常:0x8007000B)
----> System.BadImageFormatException : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
这是否有些事情要和我没有正确预计code,或者是它在我的模拟,还是其他什么东西相关的多个接口?
Does this have something to do with my not having the right Expect code, or is it related to the multiple interfaces in my mock, or something else?
推荐答案
我发现这个链接:城项目主题
,这似乎表明,在城堡的DynamicProxy,它用于通过起订量(和RhinoMocks)
which seems to indicate that its a problem in Castle's DynamicProxy, which is used by Moq (and RhinoMocks).
这篇关于起订量多接口问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!