Ejemplo n.º 1
0
        public void TestConstructWithChannelInitializer()
        {
            int              first    = 1;
            int              second   = 2;
            IChannelHandler  handler  = new ChannelHandler1(first, second);
            var              channel  = new EmbeddedChannel(new ActionChannelInitializer <IChannel>(ch => { ch.Pipeline.AddLast(handler); }));
            IChannelPipeline pipeline = channel.Pipeline;

            Assert.Same(handler, pipeline.FirstContext().Handler);
            Assert.True(channel.WriteInbound(3));
            Assert.True(channel.Finish());
            Assert.Equal(first, channel.ReadInbound <int>());
            Assert.Equal(second, channel.ReadInbound <int>());
            Assert.Null(channel.ReadInbound());
        }