public void TestSimpleRequestWithData()
        {
            var data = "Some Request Data.";

            // Arrange
            string requestData = null;
            using(TestWebServer svr = new TestWebServer(
                (request, response) =>
                    {
                        requestData = ReadAsciiStringFromStream(request.InputStream);
                    }))
            {
                svr.AddPath("/blah/");
                svr.Start();

                // Act
                var request = (HttpWebRequest) WebRequest.Create(
                                                   "http://localhost:34672/blah/");
                request.Method = "post";

                WriteAsciiStringToStream(request.GetRequestStream(), data);
                request.GetResponse();

                // Assert
                Assert.That(requestData, Is.EqualTo(data));
            }
        }
        public void TestDoubleDispose()
        {
            // Arrange
            using(TestWebServer svr = new TestWebServer(
                (req, resp) => { }))
            {
                svr.AddPath("/");
                svr.Start();

                // Act
                svr.Dispose();
                svr.Dispose();

                // Success if no exceptions were thrown
            }
        }
        public void TestSimpleResponse()
        {
            // Arrange
            using(TestWebServer svr = new TestWebServer(
                (request, response) =>
                    {
                        WriteAsciiStringToStream(response.OutputStream, "A sample response.");
                        response.OutputStream.Close();
                    }))
            {
                svr.AddPath("/blah/");
                svr.Start();

                // Act
                var request = (HttpWebRequest) WebRequest.Create(
                                                   "http://localhost:34672/blah/");

                var response = request.GetResponse();
                var value = ReadAsciiStringFromStream(response.GetResponseStream());

                // Assert
                Assert.That(value, Is.EqualTo("A sample response."));
            }
        }