I am seeing a test fail when changing from a strict mock to a dynamic
one. I am at a loss as to why this is happening.

I am using what is currently on the trunk (3.5.0.1337) revision 1970

This is the test when it passes:

[Test]
public void CanCheckExists()
{
    var dataAccess = _mocks.StrictMock<ClaimDataAccess>();
    var translator = _mocks.DynamicMock<LegacyTranslator>();
    IClaimRepository repository = NewRepositoryWith(dataAccess,
translator);

    Payment paymentToFind = New.Payment.PaidBy(New.BacsTransfer);
    const int owningClaimNumber = 1;

    using (_mocks.Record())
    {
        var legacyPayments = new[] { ExampleLegacyPayment,
ExampleLegacyPayment };
        Expect.Call(translator.ConvertToLegacyPayments(paymentToFind,
owningClaimNumber)).Return(legacyPayments);

        Expect.Call(dataAccess.Exists(legacyPayments[0])).Return
(true);
        Expect.Call(dataAccess.Exists(legacyPayments[1])).Return
(true);

        var reportingRecords
            = new[] { ExampleLegacyReportingRecord,
ExampleLegacyReportingRecord };
        Expect.Call(translator.ConvertToLegacyPaymentReportingRecords
(paymentToFind, owningClaimNumber))
            .Return(reportingRecords);

        Expect.Call(dataAccess.Exists(reportingRecords[0])).Return
(true);
        Expect.Call(dataAccess.Exists(reportingRecords[1])).Return
(true);
    }

    using (_mocks.Playback())
    {
        Assert.That(repository.Exists(paymentToFind,
owningClaimNumber), Is.True);
    }
}

When I change the test as follows

  var dataAccess = _mocks.DynamicMock<ClaimDataAccess>();

The verification fails on two of the expectations. The message is:

ClaimDataAccess.Exists(LegacyPayment<snip>)); Expected #1, Actual #0.
ClaimDataAccess.Exists(LegacyPaymentReportingRecord<snip>)); Expected
#1, Actual #0.


Here is a little more context:
1) ExampleLegacyPayment and ExampleLegacyReportingRecord are both
properties that return a new instance on each call. Both properties
return objects that are value equivalent
2) The LegacyPayment and LegacyPaymentReportingRecord class both
override the Equals method
3) I can make the dynamic mock "work" by making ExampleLegacyPayment
and ExampleLegacyReportingRecord return object's with different values
each time
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to