Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPackUnpackBytesHeaderWithCorrectBufferSize() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldPackUnpackBytesHeaderWithCorrectBufferSize()
        {
            Machine machine = new Machine();

            PackStream.Packer packer = machine.Packer();

            MachineClient client = new MachineClient(8);

            PackStream.Unpacker unpacker = client.Unpacker();

            for (int size = 0; size <= 65536; size++)
            {
                machine.Reset();
                packer.PackBytesHeader(size);
                packer.Flush();

                // Then
                int     bufferSize = ComputeOutputBufferSize(size, false);
                sbyte[] output     = machine.Output();
                assertThat(output.Length, equalTo(bufferSize));

                client.Reset(output);
                int value = unpacker.UnpackBytesHeader();
                assertThat(value, equalTo(size));
            }
        }