From: Barry K. <bk...@in...> - 2002-11-17 23:11:57
|
Steve Freeman wrote: > Thanks for your proposal in another message. > > You might also consider combining the dynamic mock with a hand-rolled > mock using the ExpectationSet, e.g. > > public void MockFoo extends Mock { > ExpectationSet values = new ExpectationSet("values); > > public void addValue(Value aValue) { // override > values.addActual(aValue); > } > > public void verify() { > super.verify(); > values.verify(); > } > } > I'm still a bit confused. Consider: public void class QuantityHolder { public int getQuantity(Key key1, Key key1); } public int sum(QuantityHolder holder) { int result = holder.getQuantity("key1", "key2") + holder.getQuantity("key3", "key4") + ...; } I want to mock QuantityHolder. I want to ensure that sum() invoked the getQuantity method twice, with the correct keys, but in any order. I don't see how the ExpectationSet can do this. How to specify the mock return value for each key1/key2 combination? Can I use the Constraints with ExpectationSet (for mulitple arguments)? -bk BTW, are there any other examples floating around (ie, projects that make extensive use of mockobjects)? The ones the distribution are ok, but not too extensive. |