Closed GoogleCodeExporter closed 9 years ago
Original comment by JohnnyJianHY
on 12 Oct 2008 at 12:16
Original comment by JohnnyJianHY
on 22 Nov 2008 at 1:39
Original comment by JohnnyJianHY
on 22 Nov 2008 at 1:39
What is the expected behavior with both
mock.put(1, 2).stub()
mock.put(1, 2).times(1..2)
are called?
What about
mock.put(1, 2).never()
mock.put(1, 2).atLeast(1)
?
Original comment by JohnnyJianHY
on 22 Nov 2008 at 2:44
I tried in EasyMock, it throws an IllegalStateException while the second line
is
called.
Maybe we can follow EasyMock. I will read the source code of EasyMock and try
to
find out the logic of when to throw an ISE.
Original comment by JohnnyJianHY
on 22 Nov 2008 at 3:14
The way easymock behave seems sensible to me.
I don't know how it has been implemented in Easymock but I think that if we
have an
object that represent the multiplicity then we could ask it if it is compatible
with
other multiplicity already register on the mock.
Original comment by julien.g...@gmail.com
on 22 Nov 2008 at 4:12
The logic is very simple: A fixed count(e.g. times(1)) can be followed by
anything,
but a non-fixed count(that is, times(1..2), stub(), never(), atLeast and
atMost)
cannot.
For example:
mock.put(1, 2).times(1)
mock.put(1, 2).times(2)
mock.put(1, 2).times(1..2)
is fine, but
mock.put(1, 2).times(1..2)
mock.put(1, 2).times(2)
will throw an ISE.
Original comment by JohnnyJianHY
on 23 Nov 2008 at 4:44
Original comment by JohnnyJianHY
on 24 Nov 2008 at 3:16
Original issue reported on code.google.com by
julien.g...@gmail.com
on 12 Oct 2008 at 10:18