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?
How to mock everything?
781 Views Asked by Primary Key At
2
There are 2 best solutions below
0

Mock Everything is one of the feature for Mock frameworks. Mock everything in short is to mock everything in a class, such as
- mock dependent objects
- non-virtual methods
- sealed classes
- static methods
- static classes
- non-public members
- non-public types
JustMock & TypeMock both provide this feature.
You can actually look at source code of some open source mock frameworks such as Moq framework ,Easy Mock, Rhino Mocks etc.
Disclosure: Please note that link provided is of my own website
Typemock Isolator for example uses the CLR profiler API to intercept .NET calls and change them during runtime:
Quote: