public async Task TheWriteResponseBodyAsyncMethodShouldReturnStatusCode400IfFieldsMalformed()
        {
            // Arrange
            Mock.Get(this.httpResponse)
            .SetupGet(httpResponse => httpResponse.StatusCode)
            .Returns(200);

            Mock.Get(this.queryCollection)
            .Setup(queryCollection => queryCollection.ContainsKey("fields"))
            .Returns(true);

            Mock.Get(this.queryCollection)
            .SetupGet(queryCollection => queryCollection["fields"])
            .Returns("foo/");

            var writeContext = new OutputFormatterWriteContext(this.httpContext, (stream, encoding) => new StringWriter(this.body), typeof(object), new {});
            var formatter    = new PartialJsonOutputFormatter(new JsonSerializerSettings(), Mock.Of <ArrayPool <char> >(), false);

            // Act
            await formatter.WriteResponseBodyAsync(writeContext, Encoding.UTF8);

            // Assert
            Mock.Get(this.httpResponse)
            .VerifySet(httpResponse => httpResponse.StatusCode = 400);
        }
        public async Task TheWriteResponseBodyAsyncMethodShouldBypassPartialResponseIfStatusCodeIsNot200()
        {
            // Arrange
            Mock.Get(this.httpResponse)
            .SetupGet(httpResponse => httpResponse.StatusCode)
            .Returns(500);

            Mock.Get(this.queryCollection)
            .Setup(queryCollection => queryCollection.ContainsKey("fields"))
            .Returns(true);

            Mock.Get(this.queryCollection)
            .SetupGet(queryCollection => queryCollection["fields"])
            .Returns("");

            var value = new { foo = "bar" };

            var writeContext = new OutputFormatterWriteContext(this.httpContext, (stream, encoding) => new StringWriter(this.body), typeof(object), value);
            var formatter    = new PartialJsonOutputFormatter(new JsonSerializerSettings(), Mock.Of <ArrayPool <char> >(), false);

            // Act
            await formatter.WriteResponseBodyAsync(writeContext, Encoding.UTF8);

            // Assert
            Assert.Equal("{\"foo\":\"bar\"}", this.body.ToString());
        }