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
Is there a way to verify that a method was called and then later in the same test verify that the method was not called, as in this picture?

[ img ]
asked by Neil (27.7k points)

2 Answers

0 votes
Hi Neil,

You need to clean up the fakes between the verifications.
This should work:
[Test]
public void Test()
{
    A a = Isolate.Fake.Instance<A>(Members.CallOriginal);
    a.Method();
    Isolate.Verify.NonPublic.WasCalled(a, "PrivateMethod");
    
    Isolate.CleanUp();
    a.Method();
    Isolate.Verify.NonPublic.WasNotCalled(a, "PrivateMethod");
}


Please let me know if it helps.
answered by ohad (35.5k points)
0 votes
Thanks Ohad, Isolate.CleanUp() works:

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