Something like this:
Mock semanticsMock = new Mock(CallSemantics.class);
Pluxie pluxie = new Pluxie();
semanticsMock.expectAndReturn( "configure", C.args(C.same(pluxie)),
pluxie );
... rest of test...
Cheers,
Nat.
_______________________
Dr. Nathaniel Pryce
B13media Ltd.
http://www.b13media.com
+44 (0)7712 526 661
----- Original Message -----
From: <DeS...@em...>
To: <moc...@li...>
Sent: Wednesday, August 27, 2003 1:10 PM
Subject: [MO-java-users] How to express an expected invocation using dynamic
mocks?
> Hello,
>
> I must have scanned all documentation on the wiki by now, but I still
don't
> know how to do something simple like defining an expected invocation of a
> method on a dynamic mock.
>
> I have the following interface:
>
> public interface CallSemantics {
> Pluxie configure(Pluxie pluxieToConfigure);
> }
>
> And I'm testing that following method delegates to a CallSemantics object:
>
> Pluxie configurePluxie(Pluxie pluxieToConfigure) {
> // The 'callSemantics' object is a member.
> return callSemantics.configure(pluxieToConfigure);
> }
>
> Well, the real production method has some more lines, but I want to keep
my
> question simple.
>
> In my unit test, I define a mock of CallSemantics and mention that it
should
> expect an invocation of the configure method with a Pluxie object as an
> argument. However, I just can't figure out how to write this expectation
> using dynamic mocks:
>
> Mock semanticsMock = new Mock(CallSemantics.class);
> // How to define the expectation here?
> CallSemantics callSemanticsMock = (CallSemantics) semanticsMock.proxy();
>
> What should I write to define that I want one invocation of the method
with
> signature
>
> public Pluxie configure(Pluxie)
>
> Oh, I want the mock to return the given argument unmodified!
>
> Ringo
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Mockobjects-java-users mailing list
> Moc...@li...
> https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users
|