java - EasyMock: Expect Number of Elements in a Set -
how verify number of elements in set in easymock? class i'm testing should call method, passing in set n elements. right now, i'm matching object list:
mockfoosetreceiver.savefooset(eq(name), (list<ifooset>) anyobject()); replay(mockfoosetreceiver);
what i'd specify number of elements in set:
mockfoosetreceiver.savefooset(eq(name), setofnobject(100)); replay(mockfoosetreceiver);
or better yet, match elements in set:
mockfoosetreceiver.savefooset(eq(name), seteq(ecpectedset)); replay(mockfoosetreceiver);
do have roll own matcher, of there 1 built in? or have setofnobject
or seteq
matcher they'd share?
as sets must implement equals(..) according contract:
compares specified object set equality. returns true if specified object set, 2 sets have same size, , every member of specified set contained in set (or equivalently, every member of set contained in specified set). definition ensures equals method works across different implementations of set interface.
a simple easymock.eq(ecpectedset) job.
if it's size of set @guillaume's answer way go.
Comments
Post a Comment