Docking COM Interfaces Using Rhino Mocks

I have a COM library that I have to reference in my application, and I'm trying to mimic my interfaces.

I get exceptions when I do this MockRepository.GenerateMock<IAmAComInterface>();

I don't get an exception when I do this: MockRepository.GenerateDynamicMockWithRemoting<IAmAComInterface>();but none of my expectations check.

Am I doing something wrong?

At the moment I have a bunch of shells for all of my COM interfaces, and I mock them, but I would really like that I did not have to wrap everything.

EDIT:
Exceptions with GenerateMock:
System.TypeLoadException

With the message:
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.

When using the GenerateDynamicMockWithRemoting test, the error always says: Expected: 1 Actual: 0 for any expectations on the COM interface.

Using Rhino.Mocks 3.6.

+5
2

, .NET 4.0 " ". . : http://code.google.com/p/moq/issues/detail?id=254

( ) , :

Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(typeof (TypeIdentifierAttribute));

unit test.

+13
+2

All Articles