Hi,
Actually, the default (and currently only supported) behavior for AAA methods is to repeat always. Your call should always be ignored.
What happened in your test, however, is that you tried to swap a future instance twice without specifying the Swap directive twice - the first instance was swapped when the call to 'new MyLogger()' was made, and on the second time that call was made you received a real object instead of the fake one.
In order to fix the test you need to either call Swap twice, or use the same instance of MyLogger that was swapped with the fake object - which version to use depends on what you would like to test.
Swapping twice looks like this:
MyLogger fake = Isolate.Fake.Instance<MyLogger>();
Isolate.Swap<MyLogger>().With(fake);
Isolate.Swap<MyLogger>().With(fake);
MyLogger real1 = new MyLogger();
MyLogger real2 = new MyLogger();
real1.IncreaseCallNumber2();
real2.IncreaseCallNumber2();
Assert.AreEqual(0, real1.callNumber);
Assert.AreEqual(0, real2.callNumber);
Using the same real instance should look like this:
MyLogger fake = Isolate.Fake.Instance<MyLogger>();
Isolate.Swap<MyLogger>().With(fake);
MyLogger real = new MyLogger();
real.IncreaseCallNumber2();
real.IncreaseCallNumber2();
Assert.AreEqual(0, real.callNumber);
Hope this helps,
Doron
Typemock Support