Esempio n. 1
0
        public void should_fill_response_properties()
        {
            // Arrange
            var restResponseStub = new RestResponseStub();
            restResponseStub.Content = "HTTP/1.1 200 OK\nServer: Apache\n\n<html>some text </html>";
            restResponseStub.StatusCode = HttpStatusCode.Accepted;
            restResponseStub.Headers = new Parameter[] { new Parameter(), new Parameter() };

            HttpClient httpClient = CreateClient(restResponseStub);

            string method = "get";
            string url = "http://www.example.com";
            string contentType = "text/html";
            string postBody = "";
            var headers = new List<HeaderItem>();

            // Act
            HttpResponse response = httpClient.ExecuteRequest(method, url, contentType, postBody, headers);

            // Assert
            Assert.AreEqual(restResponseStub.StatusCode, response.StatusCode);
            Assert.AreEqual(restResponseStub.Content, response.Content);
            Assert.AreEqual(restResponseStub.Headers.Count, response.Headers.Count);
        }
Esempio n. 2
0
        public void should_return_expected_html_content()
        {
            // Arrange
            var restResponse = new RestResponseStub()
            {
                Content = "<html>some text </html>"
            };
            HttpClient httpClient = CreateClient(restResponse);

            string method = "get";
            string url = "http://www.example.com";
            string contentType = "text/html";
            string postBody = "";
            var headers = new List<HeaderItem>();

            // Act
            HttpResponse response = httpClient.ExecuteRequest(method, url, contentType, postBody, headers);

            // Assert
            Assert.NotNull(response);
            Assert.AreEqual(restResponse.Content, response.Content);
        }