示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeMessageWithSingleChunk()
        public virtual void ShouldDecodeMessageWithSingleChunk()
        {
            assertFalse(_channel.writeInbound(wrappedBuffer(new sbyte[] { 1, 2, 3, 4, 5 })));
            assertTrue(_channel.writeInbound(wrappedBuffer(new sbyte[0])));
            assertTrue(_channel.finish());

            assertEquals(1, _channel.inboundMessages().size());
            assertByteBufEquals(wrappedBuffer(new sbyte[] { 1, 2, 3, 4, 5 }), _channel.readInbound());
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeFullChunk()
        public virtual void ShouldDecodeFullChunk()
        {
            // whole chunk with header and body arrives at once
            ByteBuf input = buffer();

            input.writeShort(7);
            input.writeByte(1);
            input.writeByte(11);
            input.writeByte(2);
            input.writeByte(22);
            input.writeByte(3);
            input.writeByte(33);
            input.writeByte(4);

            // after buffer is written there should be something to read on the other side
            assertTrue(_channel.writeInbound(input));
            assertTrue(_channel.finish());

            // there should only be a single chunk available for reading
            assertEquals(1, _channel.inboundMessages().size());
            // it should have no size header and expected body
            assertByteBufEquals(input.slice(2, 7), _channel.readInbound());
        }