I\'m developing a small TCP server, which will process some TCP packets and behave differently based on the request.
How can I write unit test for this? If it\'s really
I don't know anything about .net, but I can tell you about unit testing.
You need to factor things out. For example, your server might run in a thread and do some work. Where it does the work should be inside a function. You also probably have a request object. Make the tcp server's "work function" take the request object as a parameter. Then unit test as usual: at the beginning of the test, setup the request, and pass it to the tcp server object's "work function". Don't actually have the server open sockets or anything. You are just unit testing the methods that do the work, and only testing the handling of the request. You are not testing sockets or network reliability or anything like that. You need to test that stuff differently.