public async Task GetResponseMessage_returns_an_HttpResponseMessage_when_given_OnPremiseTargetResponse_is_null() { IHttpResponseMessageBuilder sut = new HttpResponseMessageBuilder(null); var onPremiseTargetRequest = new OnPremise.OnPremiseConnectorResponse { StatusCode = HttpStatusCode.NotFound, Body = new byte[] { 0, 0, 0, 0 }, HttpHeaders = new Dictionary <string, string> { ["Content-Length"] = "4", ["X-Foo"] = "X-Bar", }, ContentLength = 4, }; using (var result = sut.BuildFromConnectorResponse(onPremiseTargetRequest, true, null)) { 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"); } }
public void GetResponseMessage_returns_on_premise_timeout_message_when_given_OnPremiseTargetResponse_is_null() { IHttpResponseMessageBuilder sut = new HttpResponseMessageBuilder(null); using (var result = sut.BuildFromConnectorResponse(null, true, 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"); } }