From: Nat P. <nat...@b1...> - 2003-07-02 15:13:04
|
From: "Nat Pryce" <nat...@b1...> > I think the proposed solution is very neat, and could probably also be used > to move the checks for and processing of "magic" calls from the Mock class > into Callable objects. > > However, how would it work with the OrderedMock class? Thinking about this, perhaps the whole idea of an OrderedMock is wrong. It seems that there are no cases where *all* method calls will happen in one order. Testing explicitly ordered calls is pretty rare, rare enough that having to write an extra line of code to create a CallSequence to specify the expected sequence of calls is not really a big problem. E.g. instead of: OrderedMock listener = new OrderedMock(EventListener.class); listener.expectVoid( "firstEvent", C.eq(firstEvent) ); listener.expectVoid( "secondEvent", C.eq(secondEvent) ); listener.expectVoid( "thirdEvent", C.eq(thirdEvent) ); A test would look like: Mock listener = new Mock(EventListener.class); CallCollectionBuilder eventSequence = listener.newSequence(); eventSequence.expectVoid( "firstEvent", C.eq(firstEvent) ); eventSequence.expectVoid( "secondEvent", C.eq(secondEvent) ); eventSequence.expectVoid( "thirdEvent", C.eq(thirdEvent) ); I can live with that. I even think that it makes the test more readable. Regards, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 |