예제 #1
0
        public void ClientShouldveSentPrefaceAndSettingsFrameWhenUserEventIsTriggered()
        {
            _connection.Setup(x => x.IsServer).Returns(false);
            _channel.Setup(x => x.IsActive).Returns(false);
            _handler = NewHandler();
            _channel.Setup(x => x.IsActive).Returns(true);

            var evt = Http2ConnectionPrefaceAndSettingsFrameWrittenEvent.Instance;

            AtomicBoolean verified = new AtomicBoolean(false);

            _ctx
            .Setup(x => x.FireUserEventTriggered(It.Is <object>(v => ReferenceEquals(v, evt))))
            .Returns <object>(msg =>
            {
                Assert.Same(msg, evt);
                _ctx.Verify(x => x.WriteAsync(It.Is <object>(d => Http2CodecUtil.ConnectionPrefaceBuf().Equals((IByteBuffer)d))));
                _encoder.Verify(
                    x => x.WriteSettingsAsync(
                        It.Is <IChannelHandlerContext>(v => v == _ctx.Object),
                        It.IsAny <Http2Settings>(),
                        It.IsAny <IPromise>()));
                verified.Value = true;
                return(_ctx.Object);
            });

            _handler.ChannelActive(_ctx.Object);
            Assert.True(verified.Value);
        }
예제 #2
0
 public void EncoderAndDecoderAreClosedOnChannelInactive()
 {
     _handler = NewHandler();
     _handler.ChannelActive(_ctx.Object);
     _channel.Setup(x => x.IsActive).Returns(false);
     _handler.ChannelInactive(_ctx.Object);
     _encoder.Verify(x => x.Close());
     _decoder.Verify(x => x.Close());
 }
예제 #3
0
 public void ServerShouldNotSendClientPrefaceStringWhenActive()
 {
     _connection.Setup(x => x.IsServer).Returns(true);
     _channel.Setup(x => x.IsActive).Returns(false);
     _handler = NewHandler();
     _channel.Setup(x => x.IsActive).Returns(true);
     _handler.ChannelActive(_ctx.Object);
     _ctx.Verify(x => x.WriteAsync(It.Is <object>(d => Http2CodecUtil.ConnectionPrefaceBuf().Equals((IByteBuffer)d))), Times.Never());
 }