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
(Suggestion: Please allow thread titles to be longer)

This code, where Isolate.Verify.WasNotCalled() is called on a faked method that calls a static field that was initialized by a static method, leads to an error:

[ img ]

Because I faked A, I have an expectation that in order to perform an Isolate.Verify.WasNotCalled() on A.MethodA(), I don't need to first fake every static class that A.MethodA() interacts with.

However, it appears I do need to do that:

[ img ]
Code for the above: http://pastebay.com/pastebay.php?dl=69774

Is this behavior a bug? If not, could it be changed to not require the user to have to fake every static class a faked method interacts with prior to calling Isolate.Verify.WasNotCalled() on the faked method?
asked by Neil (27.7k points)

5 Answers

0 votes
Hi Neil,

This is the expected behavior, even though I admit it's a bit confusing. We are looking into ways of removing the necessity of explicitly faking a type in order to verify against it, but in the meanwhile the way you solved it should work.

Thanks for your input.
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Thanks doron for looking into that.

There is a new problem though. I upgraded to Isolator 5.44 today and now the previously-working code above throws a NestedCallException:

[ img ]

Is this a bug? If not, how can the error message be made to go away?
answered by Neil (27.7k points)
0 votes
Neil,

This is a bug in the way we analyze nested calls. What happens is that the static method is called from within the verify statement because it's run as part of the static constructor, and we mistakenly think it's nested within the verify statement.

Until we fix the bug and to work around the issue, you can fake the static constructor too:
Isolate.Fake.StaticConstructor<A>();

This should prevent it from running inside the verify statement.

Let me know if this helps.
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Sorry, re-reading the code, you should fake static constructor on class StaticClass rather than A to work around the issue.

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Thanks doron. Faking the static constructor makes the error message go away:

[ img ]
answered by Neil (27.7k points)
...