Exemplo n.º 1
0
        public void ToString_link_with_type_should_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up", "application/json");

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; type=\"application/json\"");
        }
Exemplo n.º 2
0
        public void ToString_link_with_whitespace_parameter_should_not_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");

            link.Parameters.Add("    ", null);

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"");
        }
Exemplo n.º 3
0
        public void ToString_link_with_boolean_parameter_should_exist_without_value_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");

            link.Parameters.Add("parameter", null);

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; parameter");
        }
Exemplo n.º 4
0
        public void ToString_link_with_extension_parameter_should_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");

            link.Parameters.Add("ext", "extension-param");

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; ext=\"extension-param\"");
        }
Exemplo n.º 5
0
        async Task <XElement> DownloadXml()
        {
            using (var httpClient = _http.CreateClient())
            {
                var response = await httpClient.GetAsync(_link.ToString());

                response.EnsureSuccessStatusCode();

                var data = await response.Content.ReadAsStreamAsync();

                return(XDocument.Load(data).Root);
            }
        }
Exemplo n.º 6
0
        public async Task Download(HttpLink link)
        {
            using (var httpClient = _http.CreateClient())
            {
                var response = await httpClient.GetAsync(link.ToString());

                response.EnsureSuccessStatusCode();

                var data = await response.Content.ReadAsStreamAsync();

                await _folder.WriteFile(link, data);
            }
        }
Exemplo n.º 7
0
        public void ToString_link_with_whitespace_parameter_should_not_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");
            link.Parameters.Add("    ", null);

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"");
        }
Exemplo n.º 8
0
        public void ToString_link_with_type_should_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up", "application/json");

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; type=\"application/json\"");
        }
Exemplo n.º 9
0
        public void ToString_link_with_extension_parameter_should_exist_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");
            link.Parameters.Add("ext", "extension-param");

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; ext=\"extension-param\"");
        }
Exemplo n.º 10
0
        public void ToString_link_with_boolean_parameter_should_exist_without_value_in_string()
        {
            // Given
            var link = new HttpLink("http://nancyfx.org/", "up");
            link.Parameters.Add("parameter", null);

            // When
            var stringValue = link.ToString();

            // Then
            stringValue.ShouldEqual("<http://nancyfx.org/>; rel=\"up\"; parameter");
        }
Exemplo n.º 11
0
 public override string ToString() => Link.ToString();