Repeat times passes when actual invocation count > max

27 views
Skip to first unread message

ben.biddington

unread,
Jun 22, 2009, 12:15:40 PM6/22/09
to Rhino.Mocks
When I use something like:

mock.Expect(x => x.Xxx()).Repeat.Times(4);

I am expecting x.Xxx() to be invoked exactly 4 times. I find my test
fails (as expected) provided the actual number of times it's invoked
<= 4.

My test passes (not expected) when actual number of times > 4.

This seems to be due to AbstractExpectation not accepting call once
the maximum has been reached (4 in this case).

If I modify the following property as follows, I get the expected
behaviour:

// AbstractExpectation
public bool CanAcceptCalls
{
get
{
//I don't bother to check for RepeatableOption.Never
because
//this is handled the method recorder
if (repeatableOption == RepeatableOption.Any)
return true;

// BJB, 2009-06-22
return true;
// return expected.Max == null || actualCallsCount <
expected.Max.Value;
}
}

Any tips?

Shane Courtrille

unread,
Jun 22, 2009, 2:40:23 PM6/22/09
to Rhino...@googlegroups.com

We had an earlier discussion about this and it was decided it was as designed.  I think if you use the AAA syntax and do a post assert the repeat times works as you would expect.

Reply all
Reply to author
Forward
0 new messages