I was having some trouble using Fake.AllInstances<> so I began simplifying my code and it is now as simple as it can get and it still seems to be behaving differently from what I have seen described here in the answers to other questions.
My understanding is that when I call Isolate.Fake.AllInstances<TradeSummary>(), all existing and future instances of TradeSummary will be the same as the fake returned from this call. Furthermore, I can use the returned fake to set up WhenCalled() to perform subsequent verification of method calls.
Here is my code:
TradeSummary fakeTradeSummary = Isolate.Fake.AllInstances<TradeSummary>();
Isolate.WhenCalled(() => fakeTradeSummary.Summarize(null)).CallOriginal();
TradeSummary summ = new TradeSummary();
summ.Summarize(new List<Trade>());
Assert.AreSame(fakeTradeSummary, summ);
Isolate.Verify.WasCalledWithAnyArguments(() => summ.Summarize(null));
This code fails in 2 ways that seem counter to what I am expecting.
First, the Assert.AreSame() fails because the 2 objects are not the same instance.
Second, the Verify.WasCalledWithAnyArguments() fails with the following exception:
TypeMock.TypeMockException : *** Isolate.Verify does not support objects that were not faked
using Isolate.Fake.Instance(), or passed through WhenCalled()
Am I doing anything incorrectly in this code?