Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertNextLine(String[] line, CharSeeker seeker, Mark mark, Extractors extractors) throws java.io.IOException
        private void AssertNextLine(string[] line, CharSeeker seeker, Mark mark, Extractors extractors)
        {
            foreach (string value in line)
            {
                assertTrue(seeker.Seek(mark, _delimiter));
                assertEquals(value, seeker.Extract(mark, extractors.String()).value());
            }
            assertTrue(mark.EndOfLine);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowMissingIdHeaderEntry() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowMissingIdHeaderEntry()
        {
            // GIVEN
            CharSeeker seeker     = seeker("one\ttwo");
            Extractors extractors = new Extractors(';');

            // WHEN
            Header header = DataFactories.DefaultFormatNodeFileHeader().create(seeker, _tabs, IdType.Actual, _groups);

            // THEN
            assertArrayEquals(array(Entry("one", Type.Property, extractors.String()), Entry("two", Type.Property, extractors.String())), header.Entries());
            seeker.Dispose();
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractNullForEmptyQuotedStringIfConfiguredTo()
        internal virtual void ShouldExtractNullForEmptyQuotedStringIfConfiguredTo()
        {
            // GIVEN
            Extractors         extractors = new Extractors(';', true);
            Extractor <string> extractor  = extractors.String();

            // WHEN
            extractor.Extract(new char[0], 0, 0, true);
            string extracted = extractor.Value();

            // THEN
            assertNull(extracted);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractEmptyStringForEmptyQuotedString()
        internal virtual void ShouldExtractEmptyStringForEmptyQuotedString()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            string     value      = "";

            // WHEN
            Extractor <string> extractor = extractors.String();

            extractor.Extract(value.ToCharArray(), 0, value.Length, true);

            // THEN
            assertEquals("", extractor.Value());
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailForDuplicatePropertyHeaderEntries() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailForDuplicatePropertyHeaderEntries()
        {
            // GIVEN
            CharSeeker seeker     = seeker("one:id\tname\tname:long");
            IdType     idType     = IdType.Actual;
            Extractors extractors = new Extractors('\t');

            // WHEN
            try
            {
                DataFactories.DefaultFormatNodeFileHeader().create(seeker, _tabs, idType, _groups);
                fail("Should fail");
            }
            catch (DuplicateHeaderException e)
            {
                assertEquals(Entry("name", Type.Property, extractors.String()), e.First);
                assertEquals(Entry("name", Type.Property, extractors.Long_()), e.Other);
            }
            seeker.Dispose();
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCloneExtractor()
        internal virtual void ShouldCloneExtractor()
        {
            // GIVEN
            Extractors         extractors = new Extractors(';');
            Extractor <string> e1         = extractors.String();
            Extractor <string> e2         = e1.Clone();

            // WHEN
            string v1 = "abc";

            e1.Extract(v1.ToCharArray(), 0, v1.Length, false);
            assertEquals(v1, e1.Value());
            assertNull(e2.Value());

            // THEN
            string v2 = "def";

            e2.Extract(v2.ToCharArray(), 0, v2.Length, false);
            assertEquals(v2, e2.Value());
            assertEquals(v1, e1.Value());
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveEmptyHeadersBeInterpretedAsIgnored() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHaveEmptyHeadersBeInterpretedAsIgnored()
        {
            // GIVEN
            CharSeeker seeker     = seeker("one:id\ttwo\t\tdate:long");
            IdType     idType     = IdType.Actual;
            Extractors extractors = new Extractors('\t');

            // WHEN
            Header header = DataFactories.DefaultFormatNodeFileHeader().create(seeker, _tabs, idType, _groups);

            // THEN
            assertArrayEquals(array(Entry("one", Type.Id, extractors.Long_()), Entry("two", Type.Property, extractors.String()), Entry(null, Type.Ignore, null), Entry("date", Type.Property, extractors.Long_())), header.Entries());
            seeker.Dispose();
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseDefaultRelationshipFileHeaderCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseDefaultRelationshipFileHeaderCorrectly()
        {
            // GIVEN
            CharSeeker seeker     = seeker(":START_ID\t:END_ID\ttype:TYPE\tdate:long\tmore:long[]");
            IdType     idType     = IdType.Actual;
            Extractors extractors = new Extractors('\t');

            // WHEN
            Header header = DataFactories.DefaultFormatRelationshipFileHeader().create(seeker, _tabs, idType, _groups);

            // THEN
            assertArrayEquals(array(Entry(null, Type.StartId, idType.extractor(extractors)), Entry(null, Type.EndId, idType.extractor(extractors)), Entry("type", Type.Type, extractors.String()), Entry("date", Type.Property, extractors.Long_()), Entry("more", Type.Property, extractors.LongArray())), header.Entries());
            seeker.Dispose();
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseDefaultNodeFileHeaderCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseDefaultNodeFileHeaderCorrectly()
        {
            // GIVEN
            CharSeeker seeker     = seeker("ID:ID,label-one:label,also-labels:LABEL,name,age:long");
            IdType     idType     = IdType.String;
            Extractors extractors = new Extractors(',');

            // WHEN
            Header header = DataFactories.DefaultFormatNodeFileHeader().create(seeker, _commas, idType, _groups);

            // THEN
            assertArrayEquals(array(Entry("ID", Type.Id, idType.extractor(extractors)), Entry("label-one", Type.Label, extractors.StringArray()), Entry("also-labels", Type.Label, extractors.StringArray()), Entry("name", Type.Property, extractors.String()), Entry("age", Type.Property, extractors.Long_())), header.Entries());
            seeker.Dispose();
        }
Exemplo n.º 10
0
//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();
        }