public void ServerShouldNeverSend431HeaderSizeErrorWhenEncoding()
        {
            int padding = 0;

            _handler = NewHandler();
            Http2Exception e = new HeaderListSizeException(STREAM_ID, Http2Error.ProtocolError,
                                                           "Header size exceeded max allowed size 8196", false);

            _stream.Setup(x => x.Id).Returns(STREAM_ID);
            _connection.Setup(x => x.IsServer).Returns(true);
            _stream.Setup(x => x.IsHeadersSent).Returns(false);
            _remote.Setup(x => x.LastStreamCreated).Returns(STREAM_ID);
            _frameWriter
            .Setup(x => x.WriteRstStreamAsync(
                       It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                       It.Is <int>(v => v == STREAM_ID),
                       It.Is <Http2Error>(v => v == Http2Error.ProtocolError),
                       It.Is <IPromise>(v => v == _promise)))
            .Returns(_future);

            _handler.ExceptionCaught(_ctx.Object, e);

            _encoder.Verify(
                x => x.WriteHeadersAsync(
                    It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                    It.Is <int>(v => v == STREAM_ID),
                    It.IsAny <IHttp2Headers>(),
                    It.Is <int>(v => v == padding),
                    It.Is <bool>(v => v == true),
                    It.Is <IPromise>(v => v == _promise)), Times.Never());
            _frameWriter.Verify(
                x => x.WriteRstStreamAsync(
                    It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                    It.Is <int>(v => v == STREAM_ID),
                    It.Is <Http2Error>(v => v == Http2Error.ProtocolError),
                    It.Is <IPromise>(v => v == _promise)));
        }
        public void ConnectionErrorShouldStartShutdown()
        {
            _handler = NewHandler();
            Http2Exception e = new Http2Exception(Http2Error.ProtocolError);

            _remote.Setup(x => x.LastStreamCreated).Returns(STREAM_ID);
            _handler.ExceptionCaught(_ctx.Object, e);
            var captor = new ArgumentCaptor <IByteBuffer>();

            _frameWriter.Verify(
                x => x.WriteGoAwayAsync(
                    It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                    It.Is <int>(v => v == STREAM_ID),
                    It.Is <Http2Error>(v => v == Http2Error.ProtocolError),
                    It.Is <IByteBuffer>(v => captor.Capture(v)),
                    It.Is <IPromise>(v => v == _promise)));
            var buf = captor.GetValue();

            Assert.Equal(0, buf.ReferenceCount);
            // netty future.addListener 只配置了 ChannelFutureListener 的监听,而且isDone返回的值为false
            // 所以 processGoAwayWriteResult 没有执行
            //Assert.Equal(1, buf.ReferenceCount);
            //buf.Release();
        }