Many Mock frameworks has a feature to verify if a method is called or not. However most frameworks requires that the code follows dependency injection pattern.
The code that I'm trying to test does NOT uses dependency injection pattern, therefore a mock of the object can not be injected.
Code ex.:
public class TestMeClass {
public void TransformMe() { }
}
public abstract class SomeeClass {
public SomeMethod() {
CallMeMethod();
}
private void CallMeMethod() {
TestMeClass testMeClass = new TestMeClass();
testMeClass.TransformMe();
}
}
How can I verify(unit test) that TransformMe()
is called?
Can it be done using reflections`? (Language is C#)
Jon Skeet I need you.