コード例 #1
0
ファイル: MultiReadableTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotCrossSourcesInOneRead() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotCrossSourcesInOneRead()
        {
            // given
            string source1 = "abcdefghijklm";
            string source2 = "nopqrstuvwxyz";

            string[][] data = new string[][]
            {
                new string[] { source1 },
                new string[] { source2 }
            };
            CharReadable readable = new MultiReadable(ReaderIteratorFromStrings(data, '\n'));

            // when
            char[] target = new char[source1.Length + source2.Length / 2];
            int    read   = readable.Read(target, 0, target.Length);

            // then
            assertEquals(source1.Length + 1, read);

            // and when
            target = new char[source2.Length];
            read   = readable.Read(target, 0, target.Length);

            // then
            assertEquals(source2.Length, read);

            read = readable.Read(target, 0, target.Length);
            assertEquals(1, read);
        }
コード例 #2
0
ファイル: MultiReadableTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldTrackAbsolutePosition() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldTrackAbsolutePosition()
        {
            // GIVEN
            string[][] data = new string[][]
            {
                new string[] { "this is", "the first line" },
                new string[] { "where this", "is the second line" }
            };
            RawIterator <CharReadable, IOException> readers = ReaderIteratorFromStrings(data, '\n');
            CharReadable reader = new MultiReadable(readers);

            assertEquals(0L, reader.Position());
            SectionedCharBuffer buffer = new SectionedCharBuffer(15);

            // WHEN
            reader.Read(buffer, buffer.Front());
            assertEquals(15, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertEquals(23, reader.Position(), "Should not transition to a new reader in the middle of a read");
            assertEquals("Reader1", reader.SourceDescription());

            // we will transition to the new reader in the call below
            reader.Read(buffer, buffer.Front());
            assertEquals(23 + 15, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertEquals(23 + 30, reader.Position());
            reader.Read(buffer, buffer.Front());
            assertFalse(buffer.HasAvailable());
        }