Hello Veny,
Just return a Float instance:
mock.expectAndReturn("method", C.ANY_ARGS, new Float(4.4f));
You must remember that expectAndReturn returns uses the reflection
mechanism and as such cannot return integral values. If you check the
documentation for InvocationHandler.invoke(), you will see that Sun says
to wrap the returned value in the corresponding wrapper class.
This trick also works for any other primitive values: doubles, floats,
longs, ints, shorts, bytes and characters.
Hope that helps !
Fran=E7ois
On Thu, 11 Sep 2003 19:09:38 +0800, "veny" <ve...@p2...> said:
> Hi all,
>=20
> I am new to mock object.
> I am writing some test using DynaMock and wondering what is a good
> practice
> in returning a float value using Mock.expectAndReturn(String methodName,
> Object obj) method.
>=20
> Hope to hear from you soon.
>=20
> Thanks.
>=20
> Veny
Developer of Java Gui Builder
http://jgb.sourceforge.net/
|