public void AllowsNullHeadersOnResponse() { // ARRANGE var input = GetResponse(); input.Headers = null; var mapper = new HttpMessageMapper(); // ACT var output = mapper.ToHttpMessage(input); // ASSERT output.Headers.Should().BeEmpty(); }
public void AllowsNullContentOnResponse() { // ARRANGE var input = GetResponse(); input.Content = null; var mapper = new HttpMessageMapper(); // ACT var output = mapper.ToHttpMessage(input); // ASSERT output.Content.Should().BeNull(); output.Headers.Should().HaveCount(1); output.Headers.Server.ToString().Should().Be("HttpMessageMapper"); }
public async Task ConvertsResponseToResponseMessage() { // ARRANGE var input = GetResponse(); var mapper = new HttpMessageMapper(); // ACT var output = mapper.ToHttpMessage(input); // ASSERT output.Version.Should().Be(new Version(1, 1)); output.StatusCode.Should().Be(HttpStatusCode.NotFound); output.ReasonPhrase.Should().Be("Not Found"); output.Headers.Server.Should().HaveCount(1); output.Headers.Server.ElementAt(0).ToString().Should().Be("HttpMessageMapper"); output.Content.Should().NotBeNull(); output.Content.Headers.ContentType.ToString().Should().Be("application/json"); output.Content.Headers.ContentLength.Should().Be(99); (await output.Content.ReadAsStringAsync()).Should().Be("foobar"); output.RequestMessage.Should().BeNull(); }
public async Task ConvertsRequestToRequestMessage() { // ARRANGE var input = GetRequest(); var mapper = new HttpMessageMapper(); // ACT var output = mapper.ToHttpMessage(input); // ASSERT output.Method.Should().Be(HttpMethod.Get); output.RequestUri.Should().Be(new Uri("http://example/path")); output.Version.Should().Be(new Version(1, 1)); output.Headers.UserAgent.Should().HaveCount(1); output.Headers.UserAgent.ToString().Should().Be("HttpMessageMapper"); output.Content.Should().NotBeNull(); output.Content.Headers.ContentType.ToString().Should().Be("application/json"); output.Content.Headers.ContentLength.Should().Be(99); (await output.Content.ReadAsStringAsync()).Should().Be("foobar"); output.Properties.Should().BeEmpty(); }