At 11:12 AM -0500 3/22/06, Charles Yeomans wrote:
Indeed there is. The buzzphrase you seek is "mock objects". The basic idea is that you write an object that simulates, say a database. You implement just enough behavior to enable testing of other objects.
I'll expand on this a bit from recent experience: in the case of a socket, what I've found useful is to subclass the socket, and override the Read, Write, and Lookahead methods. I make Write just append data to a string property; Read pulls data out of that same property; and Lookahead does the laundry (no, actually, it just returns data from that same property). This lets me put the rest of the socket code through its paces, using a single socket instance (of my testing subclass) as both ends of the communication.
Now, occasionally having one socket serve as both ends of the connection complicates things (depending on your protocol). When that's the case, you could just as easily make use of two test instances, set up so that Write from one appends to the buffer of the other. Then you really have a good simulation of your real sockets, ready for unit testing.
Best, - Joe -- Joseph J. Strout [EMAIL PROTECTED] _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
