Hi,
By default, WhenCalled() affects all of the overloads of a method.
What you can do is to use the DoInstead() in the following way:
Isolate.NonPublic.WhenCalled(typeof(ClassWithPrivateStaticMethods), "createReplyModel")
.DoInstead(context =>
{
if (context.Parameters.Length == 2)
{
return Isolate.Invoke.Method(typeof(ClassWithPrivateStaticMethods),
"createReplyModel",
context.Parameters);
}
return null;
});
Context is an object which allows us to get info about the parameters.
In this case I check the number of the parameters:
1) Two parameters were sent: Invoke createReplyModel using these parameters.
2) Outherwise : return null.
As for the second issue, you can do the same thing only change the condition:
if (c.Parameters[2].Equals(true) )
{
return Isolate.Invoke.Method(typeof(ClassWithPrivateStaticMethods),
"createReplyModel",
c.Parameters);
}
Here I checked the value of the second parameter and invoked the corresponding method.
Regards,
Alex,
Typemock Support