public void Put() { HttpWebServer aHttpListener = new HttpWebServer("http://127.0.0.1:8094/"); try { object aLock = new object(); string aReceivedRequest = null; aHttpListener.StartListening(x => { if (x.Request.HttpMethod == "PUT") { lock (aLock) { aReceivedRequest = x.GetRequestMessageStr(); } x.SendResponseMessage("blabla"); } else { x.Response.StatusCode = 404; } }); HttpWebResponse aWebResponse = HttpWebClient.Put(new Uri("http://127.0.0.1:8094/hello/"), "abcd"); Assert.AreEqual(HttpStatusCode.OK, aWebResponse.StatusCode); string aResponseMessage = aWebResponse.GetResponseMessageStr(); Assert.AreEqual("abcd", aReceivedRequest); Assert.AreEqual("blabla", aResponseMessage); } finally { aHttpListener.StopListening(); } }