public virtual void test_of_simple_with_header()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV1), true))
     {
         ImmutableList <string> headers = csvFile.headers();
         assertEquals(headers.size(), 2);
         assertEquals(csvFile.containsHeader("h1"), true);
         assertEquals(csvFile.containsHeader("h2"), true);
         assertEquals(csvFile.containsHeader("a"), false);
         assertEquals(csvFile.containsHeader(Pattern.compile("h.")), true);
         assertEquals(csvFile.containsHeader(Pattern.compile("a")), false);
         assertEquals(headers.get(0), "h1");
         assertEquals(headers.get(1), "h2");
         CsvRow peeked = csvFile.peek();
         CsvRow row0   = csvFile.next();
         assertEquals(row0, peeked);
         assertEquals(row0.headers(), headers);
         assertEquals(row0.lineNumber(), 2);
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "r11");
         assertEquals(row0.field(1), "r12");
         CsvRow row1 = csvFile.next();
         assertEquals(row1.headers(), headers);
         assertEquals(row1.lineNumber(), 3);
         assertEquals(row1.fieldCount(), 2);
         assertEquals(row1.field(0), "r21");
         assertEquals(row1.field(1), "r22");
         assertEquals(csvFile.hasNext(), false);
         assertThrows(() => csvFile.peek(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.peek(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.remove(), typeof(System.NotSupportedException));
     }
 }
 public virtual void test_of_simple_no_header()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV1), false))
     {
         assertEquals(csvFile.headers().size(), 0);
         assertEquals(csvFile.hasNext(), true);
         assertEquals(csvFile.hasNext(), true);
         CsvRow peeked = csvFile.peek();
         CsvRow row0   = csvFile.next();
         assertEquals(row0, peeked);
         assertEquals(row0.headers().size(), 0);
         assertEquals(row0.lineNumber(), 1);
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "h1");
         assertEquals(row0.field(1), "h2");
         CsvRow row1 = csvFile.next();
         assertEquals(row1.headers().size(), 0);
         assertEquals(row1.lineNumber(), 2);
         assertEquals(row1.fieldCount(), 2);
         assertEquals(row1.field(0), "r11");
         assertEquals(row1.field(1), "r12");
         CsvRow row2 = csvFile.next();
         assertEquals(row2.headers().size(), 0);
         assertEquals(row2.lineNumber(), 3);
         assertEquals(row2.fieldCount(), 2);
         assertEquals(row2.field(0), "r21");
         assertEquals(row2.field(1), "r22");
         assertEquals(csvFile.hasNext(), false);
         assertThrows(() => csvFile.peek(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.peek(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.remove(), typeof(System.NotSupportedException));
     }
 }
 public virtual void test_of_empty_no_header()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(""), false))
     {
         assertEquals(csvFile.headers().size(), 0);
         assertEquals(csvFile.containsHeader("a"), false);
         assertEquals(csvFile.hasNext(), false);
         assertEquals(csvFile.hasNext(), false);
         assertThrows(() => csvFile.peek(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.next(), typeof(NoSuchElementException));
         assertThrows(() => csvFile.remove(), typeof(System.NotSupportedException));
     }
 }
 public virtual void test_of_blank_row()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV3), false))
     {
         assertEquals(csvFile.hasNext(), true);
         CsvRow row0 = csvFile.next();
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "r11");
         assertEquals(row0.field(1), "r12");
         CsvRow row1 = csvFile.next();
         assertEquals(row1.fieldCount(), 2);
         assertEquals(row1.field(0), "r21");
         assertEquals(row1.field(1), "r22");
         assertEquals(csvFile.hasNext(), false);
     }
 }
 public virtual void test_of_comment_blank_no_header()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV2), false))
     {
         assertEquals(csvFile.headers().size(), 0);
         assertEquals(csvFile.hasNext(), true);
         CsvRow row0 = csvFile.next();
         assertEquals(row0.lineNumber(), 1);
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "h1");
         assertEquals(row0.field(1), "h2");
         CsvRow row1 = csvFile.next();
         assertEquals(row1.lineNumber(), 5);
         assertEquals(row1.fieldCount(), 2);
         assertEquals(row1.field(0), "r21");
         assertEquals(row1.field(1), "r22");
         assertEquals(csvFile.hasNext(), false);
     }
 }
 public virtual void test_of_headerComment()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV4), true))
     {
         assertEquals(csvFile.hasNext(), true);
         CsvRow row0 = csvFile.next();
         assertEquals(row0.lineNumber(), 3);
         assertEquals(csvFile.headers().size(), 2);
         assertEquals(csvFile.headers().get(0), "h1");
         assertEquals(csvFile.headers().get(1), "h2");
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "r1");
         assertEquals(row0.field(1), "r2");
     }
 }
 public virtual void test_of_comment_blank_with_header()
 {
     using (CsvIterator csvFile = CsvIterator.of(CharSource.wrap(CSV2), true))
     {
         ImmutableList <string> headers = csvFile.headers();
         assertEquals(headers.size(), 2);
         assertEquals(headers.get(0), "h1");
         assertEquals(headers.get(1), "h2");
         assertEquals(csvFile.hasNext(), true);
         CsvRow row0 = csvFile.next();
         assertEquals(row0.lineNumber(), 5);
         assertEquals(row0.fieldCount(), 2);
         assertEquals(row0.field(0), "r21");
         assertEquals(row0.field(1), "r22");
         assertEquals(csvFile.hasNext(), false);
     }
 }