I’m using MOQ with tdd, i’m comfortable with the simple mock objects. Now moving on to the complex objects(i.e., objects containing other objects as properties ). i have problem creating mocks for three scenarios.
-
when the method being tested wraps a static method.
-
when the method being tested wraps a read only property.
-
when the method being tested calls another method belonging to the same class.
how do i create mocks for them.how do i resolve these scenarois, are could i go foreward changing the implementation of the tested method.?
any suggesstions will be helpful.
thanks.
There are two ways around this. 1) introduce the necessary levels of abstraction, that will let you mock/stub as needed or 2) use TypeMock Isolator, which will allow you to mock almost anything through some clever (too clever, some say) IL re-engineering.