Andy Parsons
Andy Parsons

Reputation: 21

How does TypeMock mock sealed classes and non-virtual methods?

I don't want to know how to use TypeMock. I'm just intrigued as to how it manages to mock non-virtual methods and sealed or static classes. I'd like to try to do something similar - for the fun of it.

How are the generated classes apparently able to inherit from sealed classes?

Upvotes: 2

Views: 566

Answers (2)

RoyOsherove
RoyOsherove

Reputation: 3269

As I work there maybe I can help a bit. We don't actually generate code that inherits from the classes (we are not "proxy" based like rhino or moq). we simply use real instances and intercept calls to them whenever we choose. that's one of the benefits that using the profiler API gives you.

Roy.

Upvotes: 3

Frank Schwieterman
Frank Schwieterman

Reputation: 24480

Microsoft Moles does something similar, you might find more documentation for it: http://msdn.microsoft.com/en-us/library/ff798308.aspx

It ends up rebuilding the DLL being tested to call into another DLL it builds to wrap the called object (IIRC).

Upvotes: 1

Related Questions