From: Nat P. <nat...@b1...> - 2003-04-16 11:33:48
|
The way it would work is that the sequence would be added to the mock and therefore be checked to see if it matched any incoming call. The sequence would match if the callable at its head matched. Once the callable hasBeenCalled, the head would be dequeued and the sequence would then match subsequent calls against the new head. This achieves the current behaviour, makes it easier to define sequences of more than two calls, allows more flexible combinations of sequences and selections, and does not need any changes to the mock class itself because all code to deal with sequences is in the CallSequence class, and just "falls out" of the current design. Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Steve Freeman" <st...@m3...> To: "Mockobjects-Java-Dev" <moc...@li...> Sent: Wednesday, April 16, 2003 12:17 PM Subject: Re: [MO-java-dev] Java Dynamic Mocks - going to Head? > Nat Pryce wrote: > >>Callable c1 = mock.expect("setContentType".....) > >>Callable c2 = mock.expect("getWriter".....) > >>c1.expectBefore(c2) > >> > > In the new design, this would be accomplished by organising "setContentType" > > and "getWriter" into a CallSequence and adding the call sequence to the > > Mock. > > > > CallCollection seq = mock.expectSequence(); > > seq.expectVoid( "setContentType", ... ); > > seq.expectAndReturn( "getWriter", ... ); > > > > The expectBefore method will be quite messy to implement in the current > > design. Since there is already a way to achieve the same effect, I'd > > suggest not implementing expectBefore. > > We went round this a few times in discussion. We can think of three > common cases: > - I don't care about the order: > Mock > - I care about the whole sequence: > OrderedMock > - I don't care about the order /except/ for these two: > Mock plus annotations. > > The problem with getting the sequence is how to relate it to the rest of > the expectations? And I wanted to avoid having toggles and state and > general complication. The implementation is actually quite easy if the > Calleable supports a hasBeenCalled() property (we did it in the old > version). And (to me, at least) it's easier to read. > > S. > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |