Here's the pseudo test code:
SupportingClass source = GenerateSourceWithValues("TEST");
Isolate.Fake.StaticMethods(typeof(Foo), Members.CallOriginal);
AnotherClass target = AnotherClass.FactoryMethod(source);
Assert.IsNotNull(target);
Isolate.Verify.WasCalledWithExactArguments(() => Foo.FactoryMethod(source.SomeProperty));
When executing (I'm still on 5.2.2 - can't go to 5.2.3 until later this week) I get the following exception from Isolator (not very clear by the way):
***Isolate.Verify does not support objects that were not fake using Isolate.Fake.Instance(), or passed through WhenCalled().
I tried several combinations, all of which resulted in the same error message:
SupportingClass source = GenerateSourceWithValues("TEST");
Isolate.WhenCalled(() => Foo.FactoryMethod(null)).CallOriginal();
AnotherClass target = AnotherClass.FactoryMethod(source);
Assert.IsNotNull(target);
Isolate.Verify.WasCalledWithExactArguments(() => Foo.FactoryMethod(source.SomeProperty));
and
SupportingClass source = GenerateSourceWithValues("TEST");
Isolate.Fake.StaticMethods(typeof(Foo));
Isolate.WhenCalled(() => Foo.FactoryMethod(null)).CallOriginal();
AnotherClass target = AnotherClass.FactoryMethod(source);
Assert.IsNotNull(target);
Isolate.Verify.WasCalledWithExactArguments(() => Foo.FactoryMethod(source.SomeProperty));
***Using 'WithAnyArguments' method results in the same problem.
More Info:::
So because I needed this test to run I switched syntax to following and it passes - now maybe this is all because Foo.FactoryMethod is internal and I'm using InternalsVisibleTo???? But it seems like my original test (at least one of them should work)
Tests that passes:
SupportingClass source = GenerateSourceWithValues("TEST");
Isolate.NonPulbic.WhenCalled(typeof(Foo), "FactoryMethod").CallOriginal();
AnotherClass target = AnotherClass.FactoryMethod(source);
Assert.IsNotNull(target);
Isolate.Verify.NonPublic.WasCalled(typeof(Foo), "FactoryMethod");