Esempio n. 1
0
        public void Checkdata5(int bufferSize)
        {
            const string data = CsvReaderSampleData.SampleData1;

            using (CsvReader csv = new CsvReader(new StringReader(data), true, bufferSize))
            {
                CsvReaderSampleData.CheckSampleData1(csv, true);
            }
        }
Esempio n. 2
0
 public void FieldCountTest1()
 {
     using (var csv = ReadCsv.FromString(CsvReaderSampleData.SampleData1,
                                         trimmingOptions: ValueTrimmingOptions.UnquotedOnly
                                         ))
     {
         CsvReaderSampleData.CheckSampleData1(csv, false, true);
     }
 }
Esempio n. 3
0
 public void ParsingTest37()
 {
     using (var csv = ReadCsv.FromString(CsvReaderSampleData.SampleData1,
                                         hasHeaders: true,
                                         trimmingOptions: ValueTrimmingOptions.UnquotedOnly,
                                         schema: CsvReaderSampleData.SampleData1Schema))
     {
         CsvReaderSampleData.CheckSampleData1(csv, true, false);
     }
 }
Esempio n. 4
0
 public void IndexerTest1()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
     {
         for (int i = 0; i < CsvReaderSampleData.SampleData1RecordCount; i++)
         {
             string s = csv[i, 0];
             CsvReaderSampleData.CheckSampleData1(i, csv);
         }
     }
 }
Esempio n. 5
0
        public void MoveTo_WhenCalled_CurrentRecordIndexMatchesMovedToRecord()
        {
            using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
            {
                string[] headers = csv.GetFieldHeaders();

                Assert.IsTrue(csv.MoveTo(2));
                Assert.AreEqual(2, csv.CurrentRecordIndex);
                CsvReaderSampleData.CheckSampleData1(csv, false);
            }
        }
Esempio n. 6
0
 public void MoveTo_WhenCalled_AdvancesToMatchingRecord()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
     {
         for (int i = 0; i < CsvReaderSampleData.SampleData1RecordCount; i++)
         {
             Assert.IsTrue(csv.MoveTo(i));
             CsvReaderSampleData.CheckSampleData1(i, csv);
         }
     }
 }
Esempio n. 7
0
        public void IterationTest1()
        {
            using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
            {
                int index = 0;

                foreach (string[] record in csv)
                {
                    CsvReaderSampleData.CheckSampleData1(csv.HasHeaders, index, record);
                    index++;
                }
            }
        }
Esempio n. 8
0
        public void IndexerByFieldIndexTest()
        {
            using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
            {
                IDataReader reader = csv;

                string[] values = new string[CsvReaderSampleData.SampleData1RecordCount];

                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        values[i] = (string)reader[i];
                    }

                    CsvReaderSampleData.CheckSampleData1(csv.HasHeaders, csv.CurrentRecordIndex, values);
                }
            }
        }
Esempio n. 9
0
        public void IndexerByFieldIndexTest()
        {
            using (var reader = ReadCsv.FromString(
                       CsvReaderSampleData.SampleData1, hasHeaders: true, schema: CsvReaderSampleData.SampleData1Schema, trimmingOptions: ValueTrimmingOptions.UnquotedOnly)
                   )
            {
                string[] values             = new string[CsvReaderSampleData.SampleData1RecordCount];
                int      currentRecordIndex = 0;
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        values[i] = (string)reader[i];
                    }

                    CsvReaderSampleData.CheckSampleData1(true, currentRecordIndex, values);
                    currentRecordIndex++;
                }
            }
        }
Esempio n. 10
0
        public void IndexerByFieldNameTest()
        {
            using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
            {
                IDataReader reader = csv;

                string[] values = new string[CsvReaderSampleData.SampleData1RecordCount];

                while (reader.Read())
                {
                    values[0] = (string)reader[CsvReaderSampleData.SampleData1Header0];
                    values[1] = (string)reader[CsvReaderSampleData.SampleData1Header1];
                    values[2] = (string)reader[CsvReaderSampleData.SampleData1Header2];
                    values[3] = (string)reader[CsvReaderSampleData.SampleData1Header3];
                    values[4] = (string)reader[CsvReaderSampleData.SampleData1Header4];
                    values[5] = (string)reader[CsvReaderSampleData.SampleData1Header5];

                    CsvReaderSampleData.CheckSampleData1(csv.HasHeaders, csv.CurrentRecordIndex, values);
                }
            }
        }
Esempio n. 11
0
        public void IndexerByFieldNameTest()
        {
            using (var reader = ReadCsv.FromString(
                       CsvReaderSampleData.SampleData1, hasHeaders: true, trimmingOptions: ValueTrimmingOptions.UnquotedOnly)
                   )
            {
                string[] values       = new string[CsvReaderSampleData.SampleData1RecordCount];
                int      currentIndex = 0;
                while (reader.Read())
                {
                    values[0] = (string)reader[CsvReaderSampleData.SampleData1Header0];
                    values[1] = (string)reader[CsvReaderSampleData.SampleData1Header1];
                    values[2] = (string)reader[CsvReaderSampleData.SampleData1Header2];
                    values[3] = (string)reader[CsvReaderSampleData.SampleData1Header3];
                    values[4] = (string)reader[CsvReaderSampleData.SampleData1Header4];
                    values[5] = (string)reader[CsvReaderSampleData.SampleData1Header5];

                    CsvReaderSampleData.CheckSampleData1(true, currentIndex, values, true);
                    currentIndex++;
                }
            }
        }
Esempio n. 12
0
        public void GetValueTest()
        {
            using (var reader = ReadCsv.FromString(
                       CsvReaderSampleData.SampleData1, hasHeaders: true, schema: CsvReaderSampleData.SampleData1Schema, trimmingOptions: ValueTrimmingOptions.UnquotedOnly)
                   )
            {
                string[] values = new string[CsvReaderSampleData.SampleData1RecordCount];

                var currentRecordIndex = 0;
                while (reader.Read())
                {
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        object value = reader.GetValue(i);
                        values[i] = value?.ToString();
                    }

                    CsvReaderSampleData.CheckSampleData1(true, currentRecordIndex, values);
                    currentRecordIndex++;
                }
            }
        }
Esempio n. 13
0
        public void GetValuesTest()
        {
            using (var reader = ReadCsv.FromString(
                       CsvReaderSampleData.SampleData1, hasHeaders: true, schema: CsvReaderSampleData.SampleData1Schema, trimmingOptions: ValueTrimmingOptions.UnquotedOnly)
                   )
            {
                object[] objValues = new object[CsvReaderSampleData.SampleData1RecordCount];
                string[] values    = new string[CsvReaderSampleData.SampleData1RecordCount];

                int currentRecordIndex = 0;
                while (reader.Read())
                {
                    Assert.AreEqual(CsvReaderSampleData.SampleData1RecordCount, reader.GetValues(objValues));

                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        values[i] = objValues[i]?.ToString();
                    }

                    CsvReaderSampleData.CheckSampleData1(true, currentRecordIndex, values);
                    currentRecordIndex++;
                }
            }
        }