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\""); }
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\""); }
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"); }
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\""); }
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); } }
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); } }
public override string ToString() => Link.ToString();