예제 #1
0
        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());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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}).");
        }
예제 #5
0
 public void Build_EndpointOnly_ReturnsCorrectly()
 {
     Assert.Equal("https://example.com", EndpointBuilder.Build("https://example.com"));
 }
예제 #6
0
 public void Build_WithEndpointAndId_ReturnsCorrectly(string endpoint, string id, string expected)
 {
     Assert.Equal(expected, EndpointBuilder.Build(endpoint, id));
 }