I found a bug when mocking method calls on a struct and the order in which the recording statements are issued.
Here is an example where ParentalControlSettings is a Struct.
IBaseMediaTitle title = RecorderManager.CreateMockedObject<IBaseMediaTitle>();
Account account = RecorderManager.CreateMockedObject<Account>();
ParentalControlSettings settings = new ParentalControlSettings();
using (RecordExpectations recorder = RecorderManager.StartRecording()) {
recorder.ExpectAndReturn(account.ParentalControlSettings, settings);
recorder.ExpectAndReturn(settings.IsTitlePermitted(title), true);
}
Assert.IsTrue(account.ParentalControlSettings.IsTitlePermitted(title));
If I execute the above code, then I get this error:
Can not mock chained statements with 'struct' objects. Account.get_ParentalControlSettings() returns GameFly.Retail.Domain.Customer.ParentalControlSettings
however, if I change the recording block to this
using (RecordExpectations recorder = RecorderManager.StartRecording()) {
recorder.ExpectAndReturn(settings.IsTitlePermitted(title), true);
recorder.ExpectAndReturn(account.ParentalControlSettings, settings);
}
the test succeeds correctly. All I did was change the order of the expectations. Pretty weird bug if you ask me, and also a bad exception message since there isnt a chained statement.
Please let me know if you need more info.
Thanks,
Jesse