public void Post_request_is_converted_properly()
        {
            var headers = new SDK.Http.HttpHeaders();

            headers.Authorization = new SDK.Http.AuthorizationHeaderValue("Basic", "foobarabc123");

            var request = Substitute.For <SDK.Http.IHttpRequest>();

            request.Method.Returns(SDK.Http.HttpMethod.Post);

            var fakeBody = "{ 'data1': true, 'data2': 'foobar' }";

            request.Body.Returns(fakeBody);
            request.BodyContentType.Returns(string.Empty);
            request.HasBody.Returns(true);

            request.CanonicalUri.Returns(new SDK.Http.CanonicalUri("http://api.foo.bar/v1/baz"));
            request.Headers.Returns(headers);

            var adapter          = new RestSharpAdapter();
            var convertedRequest = adapter.ToRestRequest(this.baseUrl, request);

            convertedRequest.Method.ShouldBe(RestSharp.Method.POST);
            convertedRequest.RequestFormat.ShouldBe(RestSharp.DataFormat.Json);
            convertedRequest.Resource.ShouldBe("/baz");

            convertedRequest.Parameters.ShouldContain(p =>
                                                      p.Type == RestSharp.ParameterType.HttpHeader &&
                                                      p.Name == "Authorization" &&
                                                      (string)p.Value == "Basic foobarabc123");

            convertedRequest.Parameters.ShouldContain(p =>
                                                      p.Type == RestSharp.ParameterType.RequestBody &&
                                                      (string)p.Value == fakeBody);
        }
        public void Post_request_is_converted_properly()
        {
            var headers = new SDK.Http.HttpHeaders();
            headers.Authorization = new SDK.Http.AuthorizationHeaderValue("Basic", "foobarabc123");

            var request = Substitute.For<SDK.Http.IHttpRequest>();
            request.Method.Returns(SDK.Http.HttpMethod.Post);

            var fakeBody = "{ 'data1': true, 'data2': 'foobar' }";
            request.Body.Returns(fakeBody);
            request.BodyContentType.Returns(string.Empty);
            request.HasBody.Returns(true);

            request.CanonicalUri.Returns(new SDK.Http.CanonicalUri("http://api.foo.bar/v1/baz"));
            request.Headers.Returns(headers);

            var adapter = new RestSharpAdapter();
            var convertedRequest = adapter.ToRestRequest(this.baseUrl, request);

            convertedRequest.Method.ShouldBe(RestSharp.Method.POST);
            convertedRequest.RequestFormat.ShouldBe(RestSharp.DataFormat.Json);
            convertedRequest.Resource.ShouldBe("/baz");

            convertedRequest.Parameters.ShouldContain(p =>
                p.Type == RestSharp.ParameterType.HttpHeader &&
                p.Name == "Authorization" &&
                (string)p.Value == "Basic foobarabc123");

            convertedRequest.Parameters.ShouldContain(p =>
                p.Type == RestSharp.ParameterType.RequestBody &&
                (string)p.Value == fakeBody);
        }
        public void Resource_URLs_are_constructed_properly()
        {
            var request = Substitute.For <SDK.Http.IHttpRequest>();

            request.Method.Returns(SDK.Http.HttpMethod.Put);
            request.CanonicalUri.Returns(new SDK.Http.CanonicalUri("http://api.foo.bar/v1/baz"));

            var adapter          = new RestSharpAdapter();
            var convertedRequest = adapter.ToRestRequest("http://api.foo.bar/v1", request);

            convertedRequest.Resource.ShouldBe("/baz");
        }
        public void Resource_URLs_are_constructed_properly()
        {
            var request = Substitute.For<SDK.Http.IHttpRequest>();
            request.Method.Returns(SDK.Http.HttpMethod.Put);
            request.CanonicalUri.Returns(new SDK.Http.CanonicalUri("http://api.foo.bar/v1/baz"));

            var adapter = new RestSharpAdapter();
            var convertedRequest = adapter.ToRestRequest("http://api.foo.bar/v1", request);

            convertedRequest.Resource.ShouldBe("/baz");
        }