Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task <IEnumerable <string> > GetServicesAsync()
        {
            IHttpRequest request = new HttpRequest(HttpMethod.Get, address.Build(), BaseHeaders);

            IHttpResponse response = await HttpFacade.RequestAsync(request);

            HttpUtils.ThrowOnBadStatus(response, ContentSerializer);

            var services = new { resource = new List <string>() };

            return(ContentSerializer.Deserialize(response.Body, services).resource);
        }
Ejemplo n.º 2
0
        public void ShouldBuildAfterConstruction()
        {
            // Arrange
            List <string> resources = new List <string> {
                "user", "session"
            };
            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "one", 1 },
                { "two", true }
            };

            // Act
            HttpAddress addressV1 = new HttpAddress("http://localhost", RestApiVersion.V1, resources, parameters);
            HttpAddress addressV2 = new HttpAddress("http://localhost", RestApiVersion.V2, resources, parameters);

            // Assert
            addressV1.Build().ShouldBe("http://localhost/rest/user/session?one=1&two=true");
            addressV2.Build().ShouldBe("http://localhost/api/v2.0/user/session?one=1&two=true");
        }