public void AddsHeadersToRequestMessage()
            {
                var request = new Request
                {
                    BaseAddress = GitHubClient.GitHubApiUrl,
                    Endpoint = _endpoint,
                    Method = HttpMethod.Post,
                    Headers =
                    {
                        { "foo", "bar" },
                        { "blah", "blase" }
                    }
                };
                var tester = new HttpClientAdapterTester();
                
                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.Equal(2, requestMessage.Headers.Count());
                var firstHeader = requestMessage.Headers.First();
                Assert.Equal("foo", firstHeader.Key);
                Assert.Equal("bar", firstHeader.Value.First());
                var lastHeader = requestMessage.Headers.Last();
                Assert.Equal("blah", lastHeader.Key);
                Assert.Equal("blase", lastHeader.Value.First());
                Assert.Null(requestMessage.Content);
            }
            public void AddsHeadersToRequestMessage()
            {
                var request = new Request
                {
                    Method  = HttpMethod.Post,
                    Headers =
                    {
                        { "foo",  "bar"   },
                        { "blah", "blase" }
                    }
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.Equal(2, requestMessage.Headers.Count());
                var firstHeader = requestMessage.Headers.First();

                Assert.Equal("foo", firstHeader.Key);
                Assert.Equal("bar", firstHeader.Value.First());
                var lastHeader = requestMessage.Headers.Last();

                Assert.Equal("blah", lastHeader.Key);
                Assert.Equal("blase", lastHeader.Value.First());
                Assert.Null(requestMessage.Content);
            }
            public void SetsBodyAndContentType()
            {
                var request = new Request
                {
                    Method      = HttpMethod.Post,
                    Body        = "{}",
                    ContentType = "text/plain"
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.Equal("text/plain", requestMessage.Content.Headers.ContentType.MediaType);
            }
Beispiel #4
0
            public void SetsStreamBodyAndContentType()
            {
                var request = new Request
                {
                    Method      = HttpMethod.Post,
                    Body        = new MemoryStream(),
                    ContentType = "text/plain"
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.IsType <StreamContent>(requestMessage.Content);
            }
            public void SetsBodyAndContentType()
            {
                var request = new Request
                {
                    Method = HttpMethod.Post,
                    Body = "{}",
                    ContentType = "text/plain"
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.Equal("text/plain", requestMessage.Content.Headers.ContentType.MediaType);
            }
            public void SetsHttpContentBody()
            {
                var request = new Request
                {
                    Method = HttpMethod.Post,
                    Body   = new FormUrlEncodedContent(new Dictionary <string, string> {
                        { "foo", "bar" }
                    })
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.IsType <FormUrlEncodedContent>(requestMessage.Content);
                Assert.Equal("application/x-www-form-urlencoded", requestMessage.Content.Headers.ContentType.MediaType);
            }
            public void SetsStreamBodyAndContentType()
            {
                var request = new Request
                {
                    BaseAddress = GitHubClient.GitHubApiUrl,
                    Endpoint = _endpoint,
                    Method = HttpMethod.Post,
                    Body = new MemoryStream(),
                    ContentType = "text/plain"
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.IsType<StreamContent>(requestMessage.Content);
                Assert.Equal("text/plain", requestMessage.Content.Headers.ContentType.MediaType);
            }
            public void SetsStreamBodyAndContentType()
            {
                var request = new Request
                {
                    BaseAddress = GitHubClient.GitHubApiUrl,
                    Endpoint    = _endpoint,
                    Method      = HttpMethod.Post,
                    Body        = new MemoryStream(),
                    ContentType = "text/plain"
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.IsType <StreamContent>(requestMessage.Content);
                Assert.Equal("text/plain", requestMessage.Content.Headers.ContentType.MediaType);
            }
            public void EnsuresArguments()
            {
                var tester = new HttpClientAdapterTester();

                Assert.Throws <ArgumentNullException>(() => tester.BuildRequestMessageTester(null));
            }
            public void SetsHttpContentBody()
            {
                var request = new Request
                {
                    BaseAddress = GitHubClient.GitHubApiUrl,
                    Endpoint = _endpoint,
                    Method = HttpMethod.Post,
                    Body = new FormUrlEncodedContent(new Dictionary<string, string> {{"foo", "bar"}})
                };
                var tester = new HttpClientAdapterTester();

                var requestMessage = tester.BuildRequestMessageTester(request);

                Assert.NotNull(requestMessage.Content);
                Assert.IsType<FormUrlEncodedContent>(requestMessage.Content);
                Assert.Equal("application/x-www-form-urlencoded", requestMessage.Content.Headers.ContentType.MediaType);
            }
 public void EnsuresArguments()
 {
     var tester = new HttpClientAdapterTester();
     Assert.Throws<ArgumentNullException>(() => tester.BuildRequestMessageTester(null));
 }