Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldFailIfNoNewlineInChunk() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldFailIfNoNewlineInChunk()
        {
            // GIVEN
            CharReadable reader = Readables.Wrap("1234567\n89012345678901234");

            // (next chunks):                                   ^
            // (actual chunks):                             ^
            using (ClosestNewLineChunker source = new ClosestNewLineChunker(reader, 12))
            {
                // WHEN
                Source_Chunk chunk = source.NewChunk();
                assertTrue(source.NextChunk(chunk));
                assertArrayEquals("1234567\n".ToCharArray(), CharactersOf(chunk));
                assertThrows(typeof(System.InvalidOperationException), () => assertFalse(source.NextChunk(chunk)));
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldBackUpChunkToClosestNewline() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldBackUpChunkToClosestNewline()
        {
            // GIVEN
            CharReadable reader = Readables.Wrap("1234567\n8901234\n5678901234");

            // (next chunks):                                   ^            ^
            // (actual chunks):                             ^        ^
            using (ClosestNewLineChunker source = new ClosestNewLineChunker(reader, 12))
            {
                // WHEN
                Source_Chunk chunk = source.NewChunk();
                assertTrue(source.NextChunk(chunk));
                assertArrayEquals("1234567\n".ToCharArray(), CharactersOf(chunk));
                assertTrue(source.NextChunk(chunk));
                assertArrayEquals("8901234\n".ToCharArray(), CharactersOf(chunk));
                assertTrue(source.NextChunk(chunk));
                assertArrayEquals("5678901234".ToCharArray(), CharactersOf(chunk));

                // THEN
                assertFalse(source.NextChunk(chunk));
            }
        }