Пример #1
0
        public DefaultHttp2FrameWriterTest()
        {
            _http2HeadersEncoder = new DefaultHttp2HeadersEncoder(
                NeverSensitiveDetector.Instance, new HpackEncoder(false, 16, 0));

            _frameWriter = new DefaultHttp2FrameWriter(new DefaultHttp2HeadersEncoder(
                                                           NeverSensitiveDetector.Instance, new HpackEncoder(false, 16, 0)));

            _outbound = Unpooled.Buffer();

            _expectedOutbound = Unpooled.Empty;

            _promise = new TaskCompletionSource();

            _channel = new Mock <IChannel>();

            Task localAnswer(object msg)
            {
                if (msg is IByteBuffer buf)
                {
                    _outbound.WriteBytes(buf);
                }
                ReferenceCountUtil.Release(msg);
                return(TaskUtil.Completed);
            }

            Task localAnswer0(object msg, IPromise promise)
            {
                if (msg is IByteBuffer buf)
                {
                    _outbound.WriteBytes(buf);
                }
                ReferenceCountUtil.Release(msg);
                return(TaskUtil.Completed);
            }

            _ctx = new Mock <IChannelHandlerContext>();
            _ctx.Setup(x => x.WriteAsync(It.IsAny <object>())).Returns <object>(localAnswer);
            _ctx.Setup(x => x.WriteAsync(It.IsAny <object>(), It.IsAny <IPromise>())).Returns <object, IPromise>(localAnswer0);
            _ctx.Setup(x => x.Allocator).Returns(UnpooledByteBufferAllocator.Default);
            _ctx.Setup(x => x.Channel).Returns(_channel.Object);
        }
Пример #2
0
 public DefaultHttp2FrameWriter(IHttp2HeadersEncoder headersEncoder)
 {
     _headersEncoder = headersEncoder;
     _maxFrameSize   = Http2CodecUtil.DefaultMaxFrameSize;
 }