|
From: Henrik K. <Hen...@ic...> - 2001-09-11 11:12:12
|
Hi!
Vincent Massol asked med to repost this thread to the list. My original
request is at the end of this mail.
Some more comments about the suggested functions:
Actually, I frequently use the concept of expectations, for instance when
generating mock objects with MockMaker. I also used those classes as pattern
when developing mine. If i don't get it completely wrong I should use
expectations when I want to test that my mock objects' methods are called
with correct and expected parameters. What I would like to see (I havn't
been able to use Expectations for this) is a way to make lists of values to
return rather than values to expect. Below is a very simple example of ho I
currently use my ReturnCollection.
public String getString(int arg0, int arg1, int arg2){
if (actualGetStringReturnValues.hasMoreToReturn()){
return (String)actualGetStringReturnValues.getNextReturn();
}
}
Another example, this time I use ReturnCollection for both values to return
and exceptions to throw. (This code was auto generated with an extension to
MockMaker I'm currently trying to implement)
public int getScreenID() throws CSSTransStoppedException,
CSSAbendException{
myGetScreenIDCalls.inc();
if (actualGetScreenIDReturnValues.hasMoreToReturn()){
if(actualGetScreenIDReturnValues.peekNextReturn() instanceof
CSSTransStoppedException){
throw
(CSSTransStoppedException)actualGetScreenIDReturnValues.getNextReturn();
}
if(actualGetScreenIDReturnValues.peekNextReturn() instanceof
CSSAbendException){
throw
(CSSAbendException)actualGetScreenIDReturnValues.getNextReturn();
}
return
((Integer)actualGetScreenIDReturnValues.getNextReturn()).intValue();
}
else {
return myActualGetScreenIDReturnValue;
}
}
/Henrik Karlsson
-----Original Message-----
From: Vincent Massol
To: Henrik Karlsson
Sent: 2001-09-11 11:24
Subject: Re: New classes, examples attached
Thanks Henrik !
I just want to get it straight. Are you referring to the Mock Objects
project or to the Cactus one ? :)
It looks more likely it is the Mock Objects project to me ... I think
what
you are referring to already exist in the framework : it is called
lists. Can you repost your email to
moc...@li... (that's supposing you're
referring to the Mock Objects project).
However, we are always in need of help (there is so many things to do)
and
would be very glad for your help. Tell us if there is something that
you'd
like to do (we should also update the todo list).
Thanks
-Vincent
----- Original Message -----
From: "Henrik Karlsson" <hen...@ic...>
To: <vm...@oc...>
Sent: Tuesday, September 11, 2001 8:00 AM
Subject: New classes, examples attached
> Hi!
> After using mock objects for a couple of months I sometimes
> need objects that can return secuences of responses, like
> reading sequences of strings from a back end system.
> If you find these ideas useful I'll happily take part in
> developing them for future releases. I have source code
> that implements some working prototypes, see example below.
>
> I've added a couple of classes:
> public interface ReturnCollection {
> public Object getNextReturn();
> public Object peekNextReturn();
> public boolean hasMoreToReturn();
> public void addReturn(Object ReturnItem);
> public void addReturn ...
> ...
>
> public abstract class AbstractReturnCollection implements
> ReturnCollection ...
>
> public class ReturnList extends AbstractReturnCollection ...
>
> ReturnList is the first concrete class, other special
> purpose children of AbstractReturnCollection could be
> RandomReturnSet, CircularReturnSet ...
>
> /Henrik Karlsson
>
|