Ejemplo n.º 1
0
        public void TestWarningsRecordWithMapping()
        {
            using (var test = new CsvFileReader(m_ValidSetting))
            {
                test.Open(false, CancellationToken.None);
                var dataTable = new DataTable
                {
                    TableName = "DataTable",
                    Locale    = CultureInfo.InvariantCulture
                };

                dataTable.Columns.Add(test.GetName(0), test.GetFieldType(0));

                var recordNumberColumn = dataTable.Columns.Add(test.RecordNumberFieldName, typeof(int));
                recordNumberColumn.AllowDBNull = true;

                var lineNumberColumn = dataTable.Columns.Add(test.EndLineNumberFieldName, typeof(int));
                lineNumberColumn.AllowDBNull = true;

                int[] columnMapping = { 0 };
                var   warningsList  = new RowErrorCollection();
                test.CopyRowToTable(dataTable, warningsList, columnMapping, recordNumberColumn, lineNumberColumn, null);
                var dataRow = dataTable.NewRow();
                test.Read();

                //warningsList.Add(-1, "Test1");
                //warningsList.Add(0, "Test2");
                //test.AssignNumbersAndWarnings(dataRow, columnMapping, recordNumberColumn, lineNumberColumn, null, warningsList);

                //Assert.AreEqual("Test1", dataRow.RowError);
                //Assert.AreEqual("Test2", dataRow.GetColumnError(0));
            }
        }