Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#MissingMethodException与DispatchProxy和Fakeitesy_C#_Unit Testing_Exception_Castle Dynamicproxy_Fakeiteasy - Fatal编程技术网

C#MissingMethodException与DispatchProxy和Fakeitesy

C#MissingMethodException与DispatchProxy和Fakeitesy,c#,unit-testing,exception,castle-dynamicproxy,fakeiteasy,C#,Unit Testing,Exception,Castle Dynamicproxy,Fakeiteasy,我正在用.NET内核编写一个类库,并使用拦截(DispatchProxy)来处理横切关注点 现在我的问题是,当对装饰对象进行单元测试时,我会遇到以下异常: Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll Exception thrown: 'System.Exception' in FakeItEasy.dll Exception thrown: 'System.Reflection.

我正在用.NET内核编写一个类库,并使用拦截(DispatchProxy)来处理横切关注点

现在我的问题是,当对装饰对象进行单元测试时,我会遇到以下异常:

Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.dll
Exception thrown: 'System.Exception' in FakeItEasy.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in System.Private.CoreLib.dll
另外,在调试时,我注意到动态生成的对象的特定方法(用FakeiTasy模拟)没有执行


问题是您不能模拟动态生成的对象吗?或者Fakeetisy本身正在Castle.DynamicProxy中使用拦截?

请用Fakeetisy的用法更新您的问题。谢谢。@tomredfern抱歉,但我认为它太复杂了,无法包含在这里。但我明白了为什么会有例外。引发异常是因为我模拟(伪造)了一个派生类。虚拟方法导致MissingMethodException。但是现在我正在寻找一种用FakeiTeaYout模拟派生类的方法,首先,为什么要模拟一个类?没有模拟的接口吗?是的,我稍微改变了一下我的测试。这样是行不通的