コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadALongString() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadALongString()
        {
            // given

            // build a string longer than 32k
            int           stringSize = 32 * 1024 + 1;
            StringBuilder sb         = new StringBuilder();

            for (int i = 0; i < stringSize; i++)
            {
                sb.Append("x");
            }
            string lengthyString = sb.ToString();

            // we need 3 more bytes for writing the string length
            InMemoryClosableChannel channel = new InMemoryClosableChannel(stringSize + 3);

            IoPrimitiveUtils.write3bLengthAndString(channel, lengthyString);

            // when
            string stringFromChannel = IoPrimitiveUtils.read3bLengthAndString(channel);

            // then
            assertEquals(lengthyString, stringFromChannel);
        }