Hello,
One of our developers had code that in 5.2.1 ran successfully.
UserDS.UserRow usr = Isolate.Fake.Instance<UserDS>();
Isolate.WhenCalled(() => usr.CountryCode).WillReturn("DEU");
var fakeDataReader = Isolate.Fake.Instance<DataReader>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fakeDataReader.User(userID).User[0]).WillReturn(usr);
Isolate.Swap.NextInstance<DataReader>().With(fakeDataReader);
UserDS is a dataset of user records. "CountryCode" is one if its columns.
After upgrading to version 5.2.2 he received the following exception:
TypeMock.TypeMockException :
*** The call to System.Text.RegularExpressions.ExclusiveReference.Get() was made on an uninitialized field.
Tests.TestAccountManager.<>c__DisplayClass45.<ChooseFunding_WithOneBankAccountsAndOneExpiredCreditCard_ReturnsCreditCard>b__42()
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)
He suspected that this was because chained call:
fakeDataReader.User(userID).User[0]
so he changed the code:
UserDS fakeds = Isolate.Fake.Instance<UserDS>();
Isolate.WhenCalled(() => fakeds.User[0]).WillReturn(Isolate.Fake.Instance<UserDS>());
Isolate.WhenCalled(() => fakeds.User[0].CountryCode).WillReturn("DEU");
var fakeDataReader = Isolate.Fake.Instance<DataReader>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fakeDataReader.User(userID)).WillReturn(fakeds);
Isolate.Swap.NextInstance<DataReader>().With(fakeDataReader);
Now the code works, but he need to fake Dataset and Datarow separately. Before he managed with only faked row that he actually needed.
UPDATE. Previously I listed other failures related to SqlException, but they were caused by incorrect installation. Still the bug listed above remains.