public void VerifyChannelHandlerCanBeReusedInPipeline()
        {
            _connection.Setup(x => x.IsServer).Returns(true);
            _handler = NewHandler();
            // Only read the connection preface...after preface is read internal state of Http2ConnectionHandler
            // is expected to change relative to the pipeline.
            IByteBuffer preface = Http2CodecUtil.ConnectionPrefaceBuf();

            _handler.ChannelRead(_ctx.Object, preface);
            _decoder.Verify(
                x => x.DecodeFrame(
                    It.IsAny <IChannelHandlerContext>(),
                    It.IsAny <IByteBuffer>(),
                    It.IsAny <List <object> >()),
                Times.Never());

            // Now remove and add the this.handler...this is setting up the test condition.
            _handler.HandlerRemoved(_ctx.Object);
            _handler.HandlerAdded(_ctx.Object);

            // Now verify we can continue as normal, reading connection preface plus more.
            IByteBuffer prefacePlusSome = AddSettingsHeader(Unpooled.Buffer().WriteBytes(Http2CodecUtil.ConnectionPrefaceBuf()));

            _handler.ChannelRead(_ctx.Object, prefacePlusSome);
            _decoder.Verify(
                x => x.DecodeFrame(
                    It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                    It.IsAny <IByteBuffer>(),
                    It.IsAny <List <object> >()),
                Times.AtLeastOnce);
        }
 public void Dispose()
 {
     if (_handler != null)
     {
         _handler.HandlerRemoved(_ctx.Object);
     }
 }