Re: [Mockpp-devel] Question for mockpp
Brought to you by:
ewald-arnold
From: Ewald A. <mo...@ew...> - 2006-07-31 08:15:56
|
Hello, > // the fucntion return user obj whose indendifier = id > int find( int id, User & usr); > } > > i have no way to mock 'find' method with Chainable Mock Object, like, > > find_chainer.expect(once).with(eq......). if I got it right you need to return a value by reference based on another parameter to the same method: id=1 ==> usr="one" id=2 ==> usr="two" Currently this is not possible (besides of using a handcrafted method and some ReturnObjectList's :-) There is a class Outbound which could return the value. But it returns one after the other, similar to ReturnObjectList. And the decision which expectation matches and which object to return is based on all parameters. So a potential solution might be to devise a class TriggerOutbound which somehow fills in the data when the method is actually invoked (after the parameters have been evaluated). Unfortunately all of the objects are completely independent of each others. So there must be some kind of bridge to the actual variable. So the solution could look like this: Reference<User> *reference= new Reference<User>(); find_chainer.expect(once()) .with(eq(1), reference) .will(returnValue(true)) .will(triggerOutBound(reference)) I will think about this a bit more. Maybe I can find a nice solution :-) greets -- Ewald Arnold, Germany mailto:ewald at ewald-arnold dot de icq:227435282 |