|
From: Jim A. <JA...@th...> - 2004-11-01 10:18:56
|
<FONT face=3D"Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size= =3D2><DIV>Thibaut,</DIV><DIV> </DIV><DIV>( If you're still out there := -) )</DIV><DIV><BR>You probably already know the standard mocking theory - = you mock the classes which interact with class you are testing. If yo= u are testing the receiver, you should mock the server. The fact that= you have more than one server implementation should make no difference if = they all conform to the same interface (you are only testing the receiver's= actions after all).</DIV><DIV> </DIV><DIV>If you need to test the ser= ver, by all means create a mock client, but it sounds like you need both na= tive (or managed, at least) C++ unit tests *and* some kind of end-to-end te= st for the entire piece.</DIV><DIV> </DIV><DIV>Does that help at all?<= /DIV><DIV> </DIV><DIV>Jim</DIV><DIV> </DIV><DIV>ThoughtWorks</DIV= ><DIV> </DIV><FONT color=3D#990099>-----nmo...@li...= ceforge.net wrote: -----<BR><BR></FONT><blockquote style=3D"PADDING-RIGHT: = 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; M= ARGIN-RIGHT: 0px">To: nmo...@li...<BR>From: Thibaut = Barr=E8re <thi...@gm...><BR>Sent by: nmock-general-admin= @lists.sourceforge.net<BR>Date: 10/19/2004 09:38AM<BR>Subject: [Nmock-gener= al] Re: Mocking callback functions<BR><BR><FONT face=3Dmonospace size=3D2>A= nyone ? Or am I on the wrong list ?<BR><BR>regards<BR><BR>Thibaut<BR><BR><B= R>On Thu, 14 Oct 2004 11:00:26 +0200, Thibaut Barr=E8re<BR><THIBAUT.BARRERE= @GMAIL.COM>wrote:<BR>> Hi gentlemen,<BR>> <BR>> I'm really new to = mock objects, apart from very basic stuff, and would<BR>> like to have y= our opinion about the way I plan to use them.<BR>> <BR>> I am testing= interaction with remote servers, and I'm expecting to be<BR>> called in= one of several callbacks (registered to the server) in my<BR>> testfixt= ure to decide that my test has passed. Callbacks, if called,<BR>> set an= AutoResetEvent. I'm currently testing the behaviour using this<BR>> :<B= R>> <BR>> AutoResetEvent =5Fconnected =3D new AutoResetEvent(false);<= BR>> <BR>> /// <SUMMARY><BR>> /// Callback for connect test<BR>>= ; /// </SUMMARY><BR>> /// <PARAM name=3D"e"></PARAM><BR>> private v= oid Connected(object sender,ConnectionEventArgs e)<BR>> {<BR>> = // mark the event<BR>> = =5Fconnected.Set();<BR>> }<BR>> <BR>> ....<BR>> <BR>> WaitHa= ndle[] handles =3D { =5Faccepted,=5Frejected,=5Fcancelled };<BR>> Assert= .IsTrue(WaitHandle.WaitAny(handles,5000,true)!=3DWaitHandle.WaitTimeout,"No= <BR>> valid callback called.");<BR>> <BR>> I'm thinking about refa= ctoring the callbacks and waitany code inside a<BR>> mock object, with s= ome "expectations" that would do what I need. I<BR>> would then mock the= receiver, not the server.<BR>> <BR>> To give more background, the re= mote servers (~ 10 different<BR>> implementations, native c++ code) are = wrapped behind a common managed<BR>> c++ proxy interface. I couldn't man= age to see the benefits of just<BR>> mocking one of the remote server, a= s it would not test the real thing.<BR>> <BR>> What do you think of m= ocking the receiver ? Could I do better here ?<BR>> Am I totally wrong s= omewhere ?<BR>> <BR>> thanks in advance<BR>> <BR>> Thibaut<BR>&= gt;<BR><BR><BR>-------------------------------------------------------<BR>T= his SF.net email is sponsored by: IT Product Guide on ITManagersJournal<BR>= Use IT products in your business? Tell us what you think of them. Give us<B= R>Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out mo= re<BR><A href=3D"http://productguide.itmanagersjournal.com/guidepromo.tmpl"= target=3Dblank >http://productguide.itmanagersjournal.com/guidepromo.tmpl= </A><BR>=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= <BR>Nmock-general mailing list<BR>Nmo...@li...<BR><A= href=3D"https://lists.sourceforge.net/lists/listinfo/nmock-general" target= =3Dblank >https://lists.sourceforge.net/lists/listinfo/nmock-general</A><BR= ></FONT></blockquote><br></FONT>= |