Try the below test:
[Test, Isolated]
public void DtMock1()
{
Isolate.Swap.NextInstance<DateTime>().With(Isolate.Fake.Instance<DateTime>(Members.ReturnRecursiveFakes));
}
You will get :
TestCase 'DtMock1'
failed: TypeMock.TypeMockException :
*** In order to perform swapping the call to NextInstance<T>() must be completed by a call to With()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
But if I run this test
[Test, Isolated]
public void DtMock2()
{
DateTime dt = Isolate.Fake.Instance<DateTime>(Members.ReturnRecursiveFakes);
Isolate.Swap.NextInstance<DateTime>().With(dt);
}
I will get a cannot create mockobejct of struct kind of error.
I think the first error should be the same as the second one.