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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
In Isolator 6.0.4, an ArgumentOutOfRangeException is thrown when the user doesn't fake static methods before calling an Isolate.Verify method. Expected is a TypemockException that says to fake static methods if using an Isolate.Verify call.

[ img ]
----------------------
[ img ]

private static void MultiArgMethod(int x, string s, char c)
{
}

[TestMethod]
public void MutliArgMethod_Tests()
{
  Isolate.Fake.StaticMethods<TypemockTutorialTests>();
  MultiArgMethod(1, "abc", 'q');
  Isolate.Verify.WasCalledWithArguments(() => 
    MultiArgMethod(default(int), default(string), default(char)))
    .Matching((object[] args) =>
      (int)args[0] > 0 &&
      ((string)args[1]).Length == 3 &&
      Char.IsLetter((char)(args[2])));
}


This bug also happens for instance methods:
[ img ]
asked by Neil (27.7k points)

2 Answers

0 votes
Hi Neil,

In order for the Verify APIs to work, the verified method must have some interaction with the Isolator API prior to execution (either by using WhenCalled or Fake). This is why, for example, this works:

class A
{
    public void Method() { }
}

[TestMethod]
public void Method_Test()
{
    A a = new A();
    Isolate.WhenCalled(() => a.Method()).CallOriginal();

    a.Method();
    Isolate.Verify.WasCalledWithExactArguments(() => a.Method());
}


Without the WhenCalled expectation, Verify will throw a TypemockException. It seems that we have a bug that throws the ArgumentOutOfRangeException. I will add this to our bug system!

Thanks!
answered by igal (5.7k points)
0 votes
Thanks Igal!
answered by Neil (27.7k points)
...