예제 #1
0
            public async Task BuildsResponseFromResponseMessage(HttpStatusCode httpStatusCode)
            {
                var responseMessage = new HttpResponseMessage {
                    StatusCode = httpStatusCode,
                    Content    = new ByteArrayContent(Encoding.UTF8.GetBytes("{}")),
                    Headers    =
                    {
                        { "peanut", "butter" },
                        { "ele",    "phant"  }
                    }
                };
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester <object>(responseMessage);

                var firstHeader = response.Headers.First();

                Assert.Equal("peanut", firstHeader.Key);
                Assert.Equal("butter", firstHeader.Value);
                var lastHeader = response.Headers.Last();

                Assert.Equal("ele", lastHeader.Key);
                Assert.Equal("phant", lastHeader.Value);
                Assert.Equal("{}", response.Body);
                Assert.Equal(httpStatusCode, response.StatusCode);
                Assert.Null(response.ContentType);
            }
예제 #2
0
            public async Task SetsContentType(HttpStatusCode httpStatusCode)
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = httpStatusCode,
                    Content    = new StringContent("{}", Encoding.UTF8, "application/json"),
                };
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester <object>(responseMessage);

                Assert.Equal("application/json", response.ContentType);
            }
예제 #3
0
            public async Task BuildsByteArrayResponseFromResponseMessage()
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new ByteArrayContent(new byte[] { 0, 1, 1, 0, 1 }),
                };
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester <byte[]>(responseMessage);

                Assert.Equal(new byte[] { 0, 1, 1, 0, 1 }, response.BodyAsObject);
                Assert.Null(response.Body);
                Assert.Null(response.ContentType);
            }
            public async Task BuildsByteArrayResponseFromResponseMessage()
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new ByteArrayContent(new byte[] { 0, 1, 1, 0, 1 }),
                };

                responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester(responseMessage);

                Assert.Equal(new byte[] { 0, 1, 1, 0, 1 }, response.Body);
                Assert.Equal("image/png", response.ContentType);
            }
            public async Task SetsContentType()
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content = new StringContent("{}", Encoding.UTF8, "application/json"),
                };
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester(responseMessage);

                Assert.Equal("application/json", response.ContentType);
            }
            public async Task BuildsByteArrayResponseFromResponseMessage()
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content = new ByteArrayContent(new byte[] { 0, 1, 1, 0, 1}),
                };
                responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester(responseMessage);

                Assert.Equal(new byte[] { 0, 1, 1, 0, 1 }, response.Body);
                Assert.Equal("image/png", response.ContentType);
            }
            public async Task BuildsResponseFromResponseMessage(HttpStatusCode httpStatusCode)
            {
                var responseMessage = new HttpResponseMessage {
                    StatusCode = httpStatusCode,
                    Content = new ByteArrayContent(Encoding.UTF8.GetBytes("{}")),
                    Headers =
                    {
                        {"peanut", "butter"},
                        {"ele", "phant"}
                    }
                };
                var tester = new HttpClientAdapterTester();

                var response = await tester.BuildResponseTester(responseMessage);
                
                var firstHeader = response.Headers.First();
                Assert.Equal("peanut", firstHeader.Key);
                Assert.Equal("butter", firstHeader.Value);
                var lastHeader = response.Headers.Last();
                Assert.Equal("ele", lastHeader.Key);
                Assert.Equal("phant", lastHeader.Value);
                Assert.Equal("{}", response.Body);
                Assert.Equal(httpStatusCode, response.StatusCode);
                Assert.Null(response.ContentType);
            }