コード例 #1
0
        public void TestDocumentParserPropertyWithXml()
        {
            var r = new HttpResponse
            {
                ContentType = "text/xml",
                Contents = "<root/>",
            };

            Assert.IsTrue(r.DocumentParser is XmlParser);
        }
コード例 #2
0
        public void TestDocumentParserPropertyWithText()
        {
            var r = new HttpResponse
            {
                ContentType = "text/text",
                Contents = string.Empty,
            };

            Assert.IsTrue(r.DocumentParser is TextParser);
        }
コード例 #3
0
        public void TestDocumentParserPropertyWithJson()
        {
            var r = new HttpResponse
            {
                ContentType = "javascript",
                Contents = string.Empty,
            };

            Assert.IsTrue(r.DocumentParser is JsonParser);
        }
コード例 #4
0
        public void TestExistsNode()
        {
            // Arrange
            var r = new HttpResponse
            {
                ContentType = "text/xml",
                Contents = "<root><child /></root>",
            };

            // Act
            var result= r.ExistsNode("root/child", null);

            // Assert
            Assert.IsTrue(result);
        }
コード例 #5
0
        public void TestToString()
        {
            // Arrange
            var uri = fixture.Create<Uri>();
            var statusCode= fixture.Create<HttpStatusCode>();
            var lastModified = fixture.Create<DateTime>();
            var contentType = fixture.Create<string>();
            var headers = fixture.Create<NameValueCollection>();
            var cookies = fixture.Create<NameValueCollection>();
            var exception = fixture.Create<Exception>();

            // Act
            var result = new HttpResponse
            {
                Uri = uri,
                StatusCode = statusCode,
                LastModified = lastModified,
                ContentType = contentType,
                Headers = headers,
                Cookies = cookies,
                Exception = exception,
            }.ToString();

            // Assert
            Assert.AreEqual(
                string.Format("Uri={0}, StatusCode={1}, LastModified={2}, ContentType={3}, Headers={4}, Cookies={5}, Exception={6}",
                    uri,
                    statusCode,
                    lastModified,
                    contentType,
                    headers.GetString(),
                    cookies.GetString(),
                    exception),
                result);
        }
コード例 #6
0
        public void TestGetDocumentValueWithInvalidXPath()
        {
            // Arrange
            var r = new HttpResponse
            {
                ContentType = "text/xml",
                Contents = "<root><child>a</child></root>",
            };

            // Act & Assert
            r.GetDocumentValue("//(root", null);
        }
コード例 #7
0
        public void TestGetDocumentValues()
        {
            // Arrange
            var r = new HttpResponse
            {
                ContentType = "text/xml",
                Contents = "<root><child>a</child><child>b</child></root>",
            };

            // Act
            var result = r.GetDocumentValues("root/child", null).GetString();

            // Assert
            Assert.AreEqual("{a, b}", result);
        }
コード例 #8
0
        public void TestExistsNodeWithInvalidXPath()
        {
            // Arrange
            var r = new HttpResponse
            {
                ContentType = "text/xml",
                Contents = "<root><child/></root>",
            };

            // Act/Assert
            r.ExistsNode("//(root", null);
        }
コード例 #9
0
        public void TestToString()
        {
            // Arrange
            var uri = new Uri("http://yahoo.com");
            const HttpStatusCode statusCode = HttpStatusCode.OK;
            var lastModified = DateTime.Now;
            const string contentType = "text/xml";
            var headers = new NameValueCollection { { "a", "b" } };
            var cookies = new NameValueCollection { { "c", "d" } };
            var exception= new Exception("message");

            // Act
            var result = new HttpResponse
            {
                Uri = uri,
                StatusCode = statusCode,
                LastModified = lastModified,
                ContentType = contentType,
                Headers = headers,
                Cookies = cookies,
                Exception = exception,
            }.ToString();

            // Assert
            Assert.AreEqual(
                string.Format("Uri={0}, StatusCode={1}, LastModified={2}, ContentType={3}, Headers={4}, Cookies={5}, Exception={6}",
                    uri,
                    statusCode,
                    lastModified,
                    contentType,
                    headers.GetString(),
                    cookies.GetString(),
                    exception),
                result);
        }