I have a case where the code under test, product1, calls into a mocked object, mock1.Entry, where mock1 calls back to product1 which calls back into mock1.Entry. The second call to mock1.Entry does not get mocked. Is there some way to continue to mock this second call?
A simplified example:
[TestClass]
public class UnitTest1
{
public class C1
{
public void Foo(int val) { }
}
public class C2
{
private C1 _c1;
public C2(C1 c1) { _c1 = c1; }
public void FooCaller(int val)
{
if (val < 1) { _c1.Foo(val); }
}
}
[TestMethod]
public void TestMethod1()
{
C1 c1Fake = Isolate.Fake.Instance<C1>();
C2 target = new C2(c1Fake);
Isolate.WhenCalled(() => c1Fake.Foo(0)).DoInstead(
context =>
{
int passedVal = (int)context.Parameters[0];
target.FooCaller(passedVal + 1);
});
target.FooCaller(-1);
}
}
I expected:
target.FooCaller->c1Fake.FooCaller(DoInstead)->target.FooCaller->c1Fake.FooCaller(DoInstead)
instead, I got:
target.FooCaller->c1Fake.FooCaller(DoInstead)->target.FooCaller->c1Fake.FooCaller(ACTUAL METHOD)
This behavior used to work as expected in 6.0.8 and has changed in the 8.1.1.11 version that I'm now using.
Thanks,
-Kevin