public async Task ResponseWithContent()
        {
            // ARRANGE
            var ts = new HttpMockState();

            // ACT
            var response = await ts.Target.RequestAsync(ts.Request, CancellationToken.None);

            // ASSERT
            response.Address.Should().BeEquivalentTo(ts.Request.Address);
            response.StatusCode.Should().Be(ts.HttpResponseMessage.StatusCode);
            response.Headers.Keys.Should().BeEquivalentTo(new[] { "Server", "X-Powered-By", "X-CSV", "Content-Type" });
            response.Headers["Server"].Should().Be("Fake");
            response.Headers["X-Powered-By"].Should().Be("Magic");
            response.Headers["X-CSV"].Should().Be("foo, bar");
            response.Headers["Content-Type"].Should().Be("application/json; charset=utf-8");
            new StreamReader(response.Content, Encoding.UTF8).ReadToEnd().Should().Be("\"response\"");
        }
        public async Task ResponseWithoutContent()
        {
            // ARRANGE
            var ts = new HttpMockState {
                HttpResponseMessage = { Content = null }
            };

            // ACT
            var response = await ts.Target.RequestAsync(ts.Request, CancellationToken.None);

            // ASSERT
            response.Address.Should().BeEquivalentTo(ts.Request.Address);
            response.StatusCode.Should().Be(ts.HttpResponseMessage.StatusCode);
            response.Headers.Keys.Should().BeEquivalentTo(new[] { "Server", "X-Powered-By", "X-CSV" });
            response.Headers["Server"].Should().Be("Fake");
            response.Headers["X-Powered-By"].Should().Be("Magic");
            response.Headers["X-CSV"].Should().Be("foo, bar");
            response.Content.Should().BeNull();
        }
        public async Task RequestWithoutContent()
        {
            // ARRANGE
            var ts = new HttpMockState {
                Request = { Content = null, Method = AngleSharpHttpMethod.Get }
            };

            // ACT
            await ts.Target.RequestAsync(ts.Request, CancellationToken.None);

            // ASSERT
            ts.HttpRequestMessage.Method.Should().Be(NetHttpMethod.Get);
            ts.HttpRequestMessage.RequestUri.Should().Be(new Uri("http://example/path?query=value"));
            ts.HttpRequestMessage.Content.Should().BeNull();
            ts.HttpRequestMessage.Properties.Should().BeEmpty();
            ts.HttpRequestMessage.Headers.Select(p => p.Key).Should().BeEquivalentTo(new[] { "User-Agent", "Cookie" });
            ts.HttpRequestMessage.Headers.UserAgent.ToString().Should().Be("Foo/2.0");
            ts.HttpRequestMessage.Headers.Single(p => p.Key == "Cookie").Value.Should().BeEquivalentTo(new[] { "foo=bar" });
        }
        public async Task RequestWithContent()
        {
            // ARRANGE
            var ts = new HttpMockState();

            // ACT
            await ts.Target.RequestAsync(ts.Request, CancellationToken.None);

            // ASSERT
            ts.HttpRequestMessage.Method.Should().Be(NetHttpMethod.Post);
            ts.HttpRequestMessage.RequestUri.Should().Be(new Uri("http://example/path?query=value"));
            Encoding.UTF8.GetString(ts.HttpRequestMessageContent).Should().Be("\"request\"");
            ts.HttpRequestMessage.Content.Headers.Select(p => p.Key).Should().BeEquivalentTo(new[] { "Content-Type", "Content-Length" });
            ts.HttpRequestMessage.Content.Headers.ContentType.ToString().Should().Be("application/json");
            ts.HttpRequestMessage.Content.Headers.ContentLength.Should().Be(9);
            ts.HttpRequestMessage.Properties.Should().BeEmpty();
            ts.HttpRequestMessage.Headers.Select(p => p.Key).Should().BeEquivalentTo(new[] { "User-Agent", "Cookie" });
            ts.HttpRequestMessage.Headers.UserAgent.ToString().Should().Be("Foo/2.0");
            ts.HttpRequestMessage.Headers.Single(p => p.Key == "Cookie").Value.Should().BeEquivalentTo(new[] { "foo=bar" });
        }