//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertReadTextAsInputStream(java.io.File file, String text) throws java.io.IOException private void AssertReadTextAsInputStream(File file, string text) { using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) { AssertReadText(Readables.Wrap(stream, file.Path, Charset.defaultCharset(), file.length()), text); } }
public CharReadable next() { string @string = join(_data[cursor++]); return(Readables.wrap(new StringReaderAnonymousInnerClass(this, @string) , @string.Length * 2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExtractOnlyLine() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldExtractOnlyLine() { // given string firstLine = "characters of only line"; CharReadable reader = Readables.Wrap(firstLine); // when char[] firstLineCharacters = Readables.ExtractFirstLineFrom(reader); int readAfterwards = reader.Read(new char[1], 0, 1); // then assertArrayEquals(firstLine.ToCharArray(), firstLineCharacters); assertEquals(-1, readAfterwards); }
//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))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExtractFirstLine() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldExtractFirstLine() { // given string firstLine = "characters of first line"; string secondLine = "here on the second line"; CharReadable reader = Readables.Wrap(firstLine + "\n" + secondLine); // when char[] firstLineCharacters = Readables.ExtractFirstLineFrom(reader); char[] secondLineCharacters = new char[secondLine.Length]; reader.Read(secondLineCharacters, 0, secondLineCharacters.Length); // then assertArrayEquals(firstLine.ToCharArray(), firstLineCharacters); assertArrayEquals(secondLine.ToCharArray(), secondLineCharacters); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailWhenThereAreMoreThanOneSuitableFileInThere() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailWhenThereAreMoreThanOneSuitableFileInThere() { // GIVEN string text = "abcdefghijlkmnopqrstuvxyz"; File compressed = CompressWithZip(text, ".nothing", ".DS_Store", "somewhere/something"); // WHEN CharReadable readable; try { readable = Readables.Files(Charset.defaultCharset(), compressed); fail("Should fail since there are multiple suitable files in the zip archive"); } catch (IOException e) { // Good assertThat(e.Message, containsString("Multiple")); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldComplyWithSpecifiedCharset(java.nio.charset.Charset charset) throws Exception private void ShouldComplyWithSpecifiedCharset(Charset charset) { // GIVEN string data = "abcåäö[]{}"; File file = WriteToFile(data, charset); // WHEN CharReadable reader = Readables.Files(charset, file); SectionedCharBuffer buffer = new SectionedCharBuffer(100); buffer = reader.Read(buffer, buffer.Front()); // THEN char[] expected = data.ToCharArray(); char[] array = buffer.Array(); assertEquals(expected.Length, buffer.Available()); for (int i = 0; i < expected.Length; i++) { assertEquals(expected[i], array[buffer.Pivot() + i]); } }
//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)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTrackPosition() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTrackPosition() { // GIVEN string data = "1234567890"; // ^ ^ CharReadable reader = Readables.Wrap(data); SectionedCharBuffer buffer = new SectionedCharBuffer(4); // WHEN int expected = 0; do { buffer = reader.Read(buffer, buffer.Front()); expected += buffer.Available(); // THEN assertEquals(expected, reader.Position()); } while (buffer.HasAvailable()); // and THEN assertEquals(data.ToCharArray().length, expected); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldParseHeaderFromFirstLineOfFirstInputFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldParseHeaderFromFirstLineOfFirstInputFile() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.csv.reader.CharReadable firstSource = wrap("id:ID\tname:String\tbirth_date:long"); CharReadable firstSource = wrap("id:ID\tname:String\tbirth_date:long"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.csv.reader.CharReadable secondSource = wrap("0\tThe node\t123456789"); CharReadable secondSource = wrap("0\tThe node\t123456789"); DataFactory dataFactory = DataFactories.Data(value => value, () => new MultiReadable(Readables.iterator(IOFunctions.identity(), firstSource, secondSource))); Header.Factory headerFactory = defaultFormatNodeFileHeader(); Extractors extractors = new Extractors(';'); // WHEN CharSeeker seeker = CharSeekers.charSeeker(new MultiReadable(dataFactory.Create(_tabs).stream()), _tabs, false); Header header = headerFactory.Create(seeker, _tabs, IdType.Actual, _groups); // THEN assertArrayEquals(array(Entry("id", Type.Id, extractors.Long_()), Entry("name", Type.Property, extractors.String()), Entry("birth_date", Type.Property, extractors.Long_())), header.Entries()); seeker.Dispose(); }
internal TrackingReader(int length) { this.Bytes = length * 2; this.Actual = Readables.Wrap(new CharArrayReader(Chars(0, length)), length * 2); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertReadText(java.io.File file, String text) throws java.io.IOException private void AssertReadText(File file, string text) { AssertReadText(Readables.Files(Charset.defaultCharset(), file), text); }