tags:

views:

33

answers:

2

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?

+1  A: 

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 mow). 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.

RoyOsherove
+1  A: 

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).

Frank Schwieterman
Not entirely correct. Moles injects detours at runtime using the profiler as well. The compiled Moles assembly is there to provide a strongly typed way of replacing methods.
Peli