示例#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);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldFailExtractingLongArrayWhereAnyValueIsntReallyANumber()
        internal virtual void ShouldFailExtractingLongArrayWhereAnyValueIsntReallyANumber()
        {
            // GIVEN
            Extractors extractors = new Extractors(';');

            // WHEN extracting long[] from "<number>;<number>...;" i.e. ending with a delimiter
            string data = "123;456;abc;789";

            assertThrows(typeof(System.FormatException), () => extractors.ValueOf("long[]").extract(data.ToCharArray(), 0, data.Length, false));
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldFailExtractingLongArrayWhereAnyValueIsEmpty()
        internal virtual void ShouldFailExtractingLongArrayWhereAnyValueIsEmpty()
        {
            // GIVEN
            Extractors extractors = new Extractors(';');

            long[] longData = new long[] { 112233, 4455, 66778899 };
            string data     = ToString(longData, ';') + ";";

            // WHEN extracting long[] from "<number>;<number>...;" i.e. ending with a delimiter
            assertThrows(typeof(System.FormatException), () => extractors.LongArray().extract(data.ToCharArray(), 0, data.Length, false));
        }
示例#4
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);
        }
示例#5
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();
        }
示例#6
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();
        }
示例#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();
        }
示例#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();
        }
示例#9
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());
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractTwoEmptyStringsForSingleDelimiterInArrayString()
        internal virtual void ShouldExtractTwoEmptyStringsForSingleDelimiterInArrayString()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            string     value      = ",";

            // WHEN
            Extractor <string[]> extractor = extractors.StringArray();

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

            // THEN
            assertArrayEquals(new string[] { "", "" }, extractor.Value());
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractEmptyLongArrayForEmptyArrayString()
        internal virtual void ShouldExtractEmptyLongArrayForEmptyArrayString()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            string     value      = "";

            // WHEN
            Extractor <long[]> extractor = extractors.LongArray();

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

            // THEN
            assertEquals(0, extractor.Value().Length);
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotTrimStringIfNotConfiguredTo()
        internal virtual void ShouldNotTrimStringIfNotConfiguredTo()
        {
            // GIVEN
            Extractors extractors = new Extractors(';', true, false);
            string     value      = "ab;cd ; ef; gh ";

            // WHEN
            char[] asChars = value.ToCharArray();
            Extractor <string[]> extractor = extractors.StringArray();

            extractor.Extract(asChars, 0, asChars.Length, true);

            // THEN
            assertArrayEquals(new string[] { "ab", "cd ", " ef", " gh " }, extractor.Value());
        }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractNegativeInt()
        internal virtual void ShouldExtractNegativeInt()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            int        value      = -1234567;

            // WHEN
            char[]       asChars   = value.ToString().ToCharArray();
            IntExtractor extractor = extractors.Int_();

            extractor.Extract(asChars, 0, asChars.Length, false);

            // THEN
            assertEquals(value, extractor.IntValue());
        }
示例#14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractBooleanArray()
        internal virtual void ShouldExtractBooleanArray()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');

            bool[] booleanData = new bool[] { true, false, true };
            string data        = ToString(booleanData, ',');

            // WHEN
            Extractor <bool[]> extractor = extractors.BooleanArray();

            extractor.Extract(data.ToCharArray(), 0, data.Length, false);

            // THEN
            AssertBooleanArrayEquals(booleanData, extractor.Value());
        }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractStringArray()
        internal virtual void ShouldExtractStringArray()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            string     data       = "abcde,fghijkl,mnopq";

            // WHEN
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Extractor<String[]> extractor = (Extractor<String[]>) extractors.valueOf("STRING[]");
            Extractor <string[]> extractor = (Extractor <string[]>)extractors.ValueOf("STRING[]");

            extractor.Extract(data.ToCharArray(), 0, data.Length, false);

            // THEN
            assertArrayEquals(new string[] { "abcde", "fghijkl", "mnopq" }, extractor.Value());
        }
示例#16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractDoubleArray()
        internal virtual void ShouldExtractDoubleArray()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');

            double[] doubleData = new double[] { 123.123, 4567.4567, 987654321.0987 };
            string   data       = ToString(doubleData, ',');

            // WHEN
            Extractor <double[]> extractor = extractors.DoubleArray();

            extractor.Extract(data.ToCharArray(), 0, data.Length, false);

            // THEN
            assertArrayEquals(doubleData, extractor.Value(), 0.001);
        }
示例#17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractPoint()
        internal virtual void ShouldExtractPoint()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            PointValue value      = Values.pointValue(CoordinateReferenceSystem.WGS84, 13.2, 56.7);

            // WHEN
            char[] asChars = "Point{latitude: 56.7, longitude: 13.2}".ToCharArray();
            Extractors.PointExtractor extractor = extractors.Point();
            string headerInfo = "{crs:WGS-84}";

            extractor.Extract(asChars, 0, asChars.Length, false, PointValue.parseHeaderInformation(headerInfo));

            // THEN
            assertEquals(value, extractor.ValueConflict);
        }
示例#18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractLongArray()
        internal virtual void ShouldExtractLongArray()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');

            long[] longData = new long[] { 123, 4567, 987654321 };
            string data     = ToString(longData, ',');

            // WHEN
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Extractor<long[]> extractor = (Extractor<long[]>) extractors.valueOf("long[]");
            Extractor <long[]> extractor = (Extractor <long[]>)extractors.ValueOf("long[]");

            extractor.Extract(data.ToCharArray(), 0, data.Length, false);

            // THEN
            assertArrayEquals(longData, extractor.Value());
        }
示例#19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailForDuplicateIdHeaderEntries() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailForDuplicateIdHeaderEntries()
        {
            // GIVEN
            CharSeeker seeker     = seeker("one:id\ttwo:id");
            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("one", Type.Id, extractors.Long_()), e.First);
                assertEquals(Entry("two", Type.Id, extractors.Long_()), e.Other);
            }
            seeker.Dispose();
        }
示例#20
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());
        }
示例#21
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();
        }
示例#22
0
 public abstract Org.Neo4j.Csv.Reader.Extractor <JavaToDotNetGenericWildcard> extractor(Org.Neo4j.Csv.Reader.Extractors extractors);