views:

120

answers:

1

I understand how to mock interfaces or virtual method calls. But frameworks like TypeMock can mock everything in the framework. Which .NET mechanisms are used to provide such functions?

+5  A: 

Typemock Isolator for example uses the CLR profiler API to intercept .NET calls and change them during runtime:

Quote:

Typemock Isolator uses an aspect-oriented programming design that creates a mock aspect. Internally, it uses the .NET Framework profiler API to monitor an application's execution. When a method is loaded by the CLR, Typemock Isolator retrieves the IL and replaces it with instrumented IL code. Typemock Isolator does not change your original IL code, it simply inserts new code that calls the Typemock Isolator framework and returns mocked values.

Darin Dimitrov
Thanks for your reply. Could you recommend a good article about this API?
[This article](http://msdn.microsoft.com/en-us/magazine/cc300553.aspx) is a good start.
Darin Dimitrov