|
From: <thi...@gm...> - 2004-10-19 08:38:44
|
Anyone ? Or am I on the wrong list ?
regards
Thibaut
On Thu, 14 Oct 2004 11:00:26 +0200, Thibaut Barr=E8re
<thi...@gm...> wrote:
> Hi gentlemen,
>=20
> I'm really new to mock objects, apart from very basic stuff, and would
> like to have your opinion about the way I plan to use them.
>=20
> I am testing interaction with remote servers, and I'm expecting to be
> called in one of several callbacks (registered to the server) in my
> testfixture to decide that my test has passed. Callbacks, if called,
> set an AutoResetEvent. I'm currently testing the behaviour using this
> :
>=20
> AutoResetEvent _connected =3D new AutoResetEvent(false);
>=20
> /// <summary>
> /// Callback for connect test
> /// </summary>
> /// <param name=3D"e"></param>
> private void Connected(object sender,ConnectionEventArgs e)
> {
> // mark the event
> _connected.Set();
> }
>=20
> ....
>=20
> WaitHandle[] handles =3D { _accepted,_rejected,_cancelled };
> Assert.IsTrue(WaitHandle.WaitAny(handles,5000,true)!=3DWaitHandle.WaitTim=
eout,"No
> valid callback called.");
>=20
> I'm thinking about refactoring the callbacks and waitany code inside a
> mock object, with some "expectations" that would do what I need. I
> would then mock the receiver, not the server.
>=20
> To give more background, the remote servers (~ 10 different
> implementations, native c++ code) are wrapped behind a common managed
> c++ proxy interface. I couldn't manage to see the benefits of just
> mocking one of the remote server, as it would not test the real thing.
>=20
> What do you think of mocking the receiver ? Could I do better here ?
> Am I totally wrong somewhere ?
>=20
> thanks in advance
>=20
> Thibaut
>
|