From: Steve F. <st...@m3...> - 2003-04-16 11:17:07
|
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. |