chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hi, I tried to use WithArguments method with array or class instance parameters; but I always get the message that method is called with different parameters even if paramters are actually the same.
Let me clarify myself wtih an example:

public Class1
public Class2
public Class3
private void PrivateMethod(Class1 c1, Class2[] c2s)

public void PublicMethod(Class1 c1, Class2[] c2s)
PrivateMethod(c1, c2s);
public void VerifyMethodWasCalled()
Class1 c1 = new Class1();
Class2[] c2s = new Class2[2];
c2s[0] = new Class2();
c2s[1] = new Class2();
Class3 fake = Isolate.Fake.Instance<Class3>(Members.CallOriginal);


/// In this verification I got warning that PrivateMethod is called with different parameters
Isolate.Verify.NonPublic.WasCalled(fake, "PrivateMethod").WithArguments(c1, c2s);

How should I use WithArguments method with array or class instance parameters?

asked by mkg (4.3k points)

1 Answer

0 votes

We have a bug with array arguments which cause the test to fail.
You can still use DoInstead API:
Isolate.NonPublic.WhenCalled(fake, "PrivateMethod").DoInstead(context ...) to get the arguments in runtime and do your own custom code to compare the arguments.
answered by ohad (35.4k points)