public void Build_GivenBaseUrlParamWithNonDefaultPort_ReturnsEndpointWithPort() { var actual = EndpointBuilder .Build("https://example.com:1234", "test", new NameValueCollection { { "id", "123" } }); Assert.Equal("https://example.com:1234/test?id=123", actual); }
public Endpoint Build() { foreach (var convention in conventions) { convention(endpointBuiilder); } return(endpointBuiilder.Build()); }
public void Build_WithAllParams_ReturnsCorrectly(string endpoint) { var result = EndpointBuilder.Build(endpoint, "id123", new NameValueCollection { { "id", "123" }, { "name", "abc" } }); Assert.Equal("https://example.com/id123?id=123&name=abc", result); }
public async Task <int> CountAsync() { var endpoint = EndpointBuilder.Build(_baseEndpoint, "count"); var response = await _httpClient.GetAsync(endpoint); CheckStatusCode(response.StatusCode); var body = await response.Content.ReadAsStringAsync(); if (int.TryParse(body, out var count)) { return(count); } throw new InvalidOperationException($"The response body was unknown format ({body})."); }
public void Build_EndpointOnly_ReturnsCorrectly() { Assert.Equal("https://example.com", EndpointBuilder.Build("https://example.com")); }
public void Build_WithEndpointAndId_ReturnsCorrectly(string endpoint, string id, string expected) { Assert.Equal(expected, EndpointBuilder.Build(endpoint, id)); }