I have a mocked object that is passed as a constructor argument to another object.
How can I verify that the mocked object property has been called? This is the code I'm currently using:
INewContactAttributes newContact = MockRepository.GenerateMock<INewContactAttributes>(); newContact.Stub(x => x.Forenames).Return("One Two Three"); someobject.ConsumeContact(newContact); newContact.AssertWasCalled(x => { var dummy = x.Forenames; });
This works, unless the getter on Forenames property is used multiple times in "someobject". This is when I get "Rhino.Mocks.Exceptions.ExpectationViolationException: INewContactAttributes.get_Forenames (); Expected # 1, Actual # 2 .."
Just using
newContact.AssertWasCalled(x => { var dummy = x.Forenames; }, options => options.Repeat.Any());
does not work and gives an error below:
"The wait was removed from the waiting list, did you call Repeat.Any ()? This is not supported in AssertWasCalled ()."
So, how do I handle multiple calls?
c # properties unit-testing getter rhino-mocks
Confused Apr 08 '09 at 9:38 2009-04-08 09:38
source share