title: Faking TCP requests in C#
body: <p>Part of my n00b server:</p>
  
  <pre><code>TcpClient client = tcpListener.AcceptTcpClient();
  Thread clientThread = new Thread(new ParameterizedThreadStart(handleClientRegistration));
  clientThread.Start(client);
  ...
  //and in the clientThread we wait for data
  bytesRead = clientStream.Read(message, 0, 4096);
  </code></pre>
  
  <p>Now I'd like to write unit tests for this snippet. I want to fake a client connection, pass arbitrary data and check how the server handles it.</p>
  
  <p>How should I do it in C#?</p>
  
  <p>edit:<br/>
  What I'd like to mock is the connection itself - I want to avoid network connections.</p>