Exemple #1
0
        public async Task GetResponseMessage_returns_an_HttpResponseMessage_when_given_OnPremiseTargetResponse_is_null()
        {
            IHttpResponseMessageBuilder sut = new HttpResponseMessageBuilder();
            var onPremiseTargetRequest      = new OnPremiseTargetReponse
            {
                StatusCode  = HttpStatusCode.NotFound,
                Body        = new byte[] { 0, 0, 0, 0 },
                HttpHeaders = new Dictionary <string, string>
                {
                    { "Content-Length", "4" },
                    { "X-Foo", "X-Bar" }
                }
            };
            var link = new Link();
            HttpResponseMessage result;

            result = sut.BuildFrom(onPremiseTargetRequest, link);

            var content = await result.Content.ReadAsByteArrayAsync();

            result.StatusCode.Should().Be(HttpStatusCode.NotFound);
            content.LongLength.Should().Be(4L);
            result.Content.Headers.ContentLength.Should().Be(4L);
            result.Content.Headers.GetValues("X-Foo").Single().Should().Be("X-Bar");
        }
Exemple #2
0
        public void GetResponseMessage_returns_on_premise_timeout_message_when_given_OnPremiseTargetResponse_is_null()
        {
            IHttpResponseMessageBuilder sut = new HttpResponseMessageBuilder();
            HttpResponseMessage         result;

            result = sut.BuildFrom(null, null);

            result.StatusCode.Should().Be(HttpStatusCode.GatewayTimeout);
            result.Content.Headers.Count().Should().Be(1);
            result.Content.Headers.Single().Key.Should().Be("X-TTRELAY-TIMEOUT");
            result.Content.Headers.Single().Value.First().Should().Be("On-Premise");
        }