3

I'm writing a class library with .NET Core and I'm using interception (DispatchProxy) for handling cross-cutting concerns.

Now I have the problem that when unit testing the decorated object I get the following Exception:

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

Also when debugging I noticed that a specific method of a dynamically generated object (which is mocked with FakeItEasy) is not executed.

Is the problem that you can't mock dynamic generated objects? Or maybe that FakeItEasy is itself using interception with Castle.DynamicProxy?

Josh
  • 287
  • 1
  • 8
  • 1
    Kindly update your question with the fakeiteasy usage.Thank you. – tom redfern Nov 27 '19 at 10:19
  • @tomredfern sorry, but I think it's too complex to include here. But I figured out why I got the exception. The exception was thrown because I mocked(faked) a derived class. The virtual method caused the MissingMethodException. But now I'm looking for a way to mock a derived class with FakeItEasy – Josh Nov 27 '19 at 13:47
  • Out of interest, why are you mocking a class in the first place? Is there no interface to mock? – tom redfern Nov 27 '19 at 15:02
  • Yeah, I changed my tests a little bit. It wasn't going to work this way – Josh Nov 27 '19 at 15:18

0 Answers0