Maybe you’ve already seen an exception like this:
Castle.DynamicProxy.Generators.GeneratorException: Type is not public, so a proxy cannot be generated. Type: SpielWiese.IReportSender
at SpielWiese.TestSomething.ExpectReportsSend() in Program.cs: line 64
What I’ve tried is to create a mock-object with Rhino-Mock. Since this interface is only intended for usage within the assembly it’s declared as internal interface. So Rhino-Mock fails and I really don’t want to create a mock manually. The quickest and dirtiest way would be to make the interface public. But I really don’t want to leak internal stuff just for tests.
So the second approach is to make the internals visible to Rhino-Mocks.
But it will fail as well. Since Rhino uses Castle-Proxies, I tried:
It still won’t work. The reason for this is simple. The Mock-Factory has to generate code. The generated code is hosted in a separate assembly. So you have to make the dynamic assembly visible to your code under test.
This is similar with other mock frameworks or proxy-frameworks.
- Being Human