Hi,
I am using TypeMock Isolator 5.3 for mocking out private methods in my unit test. At a higher-level, calling "IgnoreCall" on a particular definition of a method that has multiple definitions does not work. TypeMock acts as if there is no "IgnoreCall" specified for that method.
Let me dive into a little bit of detail here -
Lets say I am unit-testing the following class:
public ClassA {
...
...
private static Sum(int x, int y){
--- implementation ---
}
private static Sum(Inputs inputs){
Sum(inputs.x, inputs.y)
}
...
...
}
The goal is here to verify that Sum(x, y) is called with inputs.x & inputs.y when I call Sum(inputs).
So my unit-test code looks somewhat like this -
[Test, Isolated]
public void Test_Sum_WithInputs() {
Isolate.NonPublic.WhenCalled(typeof(ClassA), "Sum").WithGenericArguments(typeof(int), typeof(int)).IgnoreCall();
Inputs inputs = new Inputs(2, 3);
// Use reflection to call the private static method
typeof(ClassA).RunStaticMethod("Sum", inputs);
Isolate.Verify.NonPublic.WasCalled(typeof(ClassA), "Sum").WithArguments(2, 3);
}
What happens when I run the test with above code?
TypeMock complains about some missing dependency in the method Sum(int x, int y). But I asked it to Ignore it, instead it would call it.
Is there a different way of unit-testing situations like this? Am I doing something wrong here?
Essentially I am trying to learn how TypeMock isolator behaves when I am dealing with overloaded methods irrespective of whether a public method is calling a public method or a private method or any other combination you can think of.
Any inputs are greatly appreciated,
Thanks,
Sudhir