Hi Peter,
For explanation why your callback method is called twice see
my answer to your previous post :)
If you want to fake only the first call of the method you can set several behavior with sequencing:
// production code
public class MyClass
{
public int Bar(string s)
{
return 1;
}
}
// test code
[Test]
public void Test()
{
var fake = Isolate.Fake.Instance<MyClass>();
Isolate.WhenCalled(() => fake.Bar(null)).WillReturn(5);
Isolate.WhenCalled(() => fake.Bar(null)).CallOriginal();
Assert.AreEqual(5, fake.Bar(null));
Assert.AreEqual(1, fake.Bar(null));
Assert.AreEqual(1, fake.Bar(null));
}
In the example above you can see when set several behaviors for a method the Isolator will apply them to the method in the order that you set in the test.
The last behavior will become the default once all expectations has been run.
In this case it means that after the first call has been faked all calls to fake.Bar() will not be faked.
Please let me know if it helps.