public void OnWrite_AppendsAcceptEncodingToVaryHeader_IfNotPresent(string providedVaryHeader, string expectedVaryHeader)
        {
            var httpContext = new DefaultHttpContext();

            httpContext.Response.Headers[HeaderNames.Vary] = providedVaryHeader;
            var stream = new BodyWrapperStream(httpContext, new MemoryStream(), new MockResponseCompressionProvider(flushable: true), null, null);

            stream.Write(new byte[] { }, 0, 0);


            Assert.Equal(expectedVaryHeader, httpContext.Response.Headers[HeaderNames.Vary]);
        }
        public void Write_IsPassedToUnderlyingStream_WhenDisableResponseBuffering(bool flushable)
        {
            var buffer = new byte[] { 1 };

            byte[] written = null;

            var mock = new Mock <Stream>();

            mock.SetupGet(s => s.CanWrite).Returns(true);
            mock.Setup(s => s.Write(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>()))
            .Callback <byte[], int, int>((b, o, c) =>
            {
                written = new ArraySegment <byte>(b, 0, c).ToArray();
            });

            var stream = new BodyWrapperStream(new DefaultHttpContext(), mock.Object, new MockResponseCompressionProvider(flushable), null, null);

            stream.DisableResponseBuffering();
            stream.Write(buffer, 0, buffer.Length);

            Assert.Equal(buffer, written);
        }