Hi,
The problem in the test is that you are swapping fakeCarRepository and use it as a return value from fakeFactory.GetRepository
The swapping is redundant here.
You can do the same with a shorter test like this:
[Test]
public void Test()
{
var fakeCarRepository = Isolate.Fake.Instance<CarRepository>();
Isolate.WhenCalled(()=> RepositoryFactory.GetInstance().GetRepository(null)).WillReturn(fakeCarRepository);
Isolate.WhenCalled(()=> CarService.MethodB()).WillReturn(true);
Isolate.WhenCalled(() => CarService. MethodC()).IgnoreCall();
CarService. MethodA();
}
:arrow: In the line:
Isolate.WhenCalled(()=> RepositoryFactory.GetInstance().GetRepository(null)).WillReturn(fakeCarRepository);
I'm faking a whole chain of calls in on line, also I don't need to specify the exact argument type for GetRepository() so I used null instead.
:arrow: Members.ReturnRecursiveFakes is the default behavior for fakes so you don't need to specify it explicitly when you're creating fakes.
This makes the line shorter and readable for future generations :D
Please let me know if solves your problem.