public async Task TimeZoneConversionsAsync() { var pd = new MockProcessDisplay(); var writeFile = (CsvFile)m_WriteFile.Clone(); writeFile.FileName = UnitTestInitializeCsv.GetTestPath("BasicCSVOut2tzc.txt"); FileSystemUtils.FileDelete(writeFile.FileName); var setting = UnitTestHelper.ReaderGetAllFormats(); UnitTestInitializeCsv.MimicSQLReader.AddSetting(setting); writeFile.SqlStatement = setting.ID; writeFile.FileFormat.FieldDelimiter = "|"; writeFile.ColumnCollection.AddIfNew( new Column("DateTime", new ValueFormatMutable() { DataType = DataType.DateTime, DateFormat = "yyyyMMdd" }) { TimePartFormat = @"hh:mm", TimePart = "Time", TimeZonePart = "TZ" }); var writer = new CsvFileWriter(writeFile, pd); var res = await writer.WriteAsync(writeFile.SqlStatement, 360, null, pd.CancellationToken); Assert.IsTrue(FileSystemUtils.FileExists(writeFile.FileName)); Assert.AreEqual(1065, res, "Records"); }
public void CsvFileClone() { var test = m_CsvFile.Clone() as CsvFile; Assert.AreNotSame(m_CsvFile, test); Assert.IsInstanceOfType(test, typeof(CsvFile)); m_CsvFile.AllPropertiesEqual(test); // Test Properties that are not tested Assert.AreEqual(m_CsvFile.MappingCollection.Count, test.MappingCollection.Count, "FieldMapping"); Assert.AreEqual(TrimmingOption.Unquoted, test.TrimmingOption, "TrimmingOption"); Assert.IsTrue(m_CsvFile.MappingCollection.CollectionEqualWithOrder(test.MappingCollection), "Mapping"); //Assert.IsTrue(m_CsvFile.Errors.CollectionEqualWithOrder(test.Errors), "Errors"); Assert.IsTrue(m_CsvFile.ColumnCollection.CollectionEqualWithOrder(test.ColumnCollection), "ColumnCollection"); Assert.IsTrue(m_CsvFile.FileFormat.Equals(test.FileFormat), "FileFormat"); Assert.IsTrue(test.Equals(m_CsvFile), "Equals"); }
public void CsvDataReaderWriteToDataTableDisplayRecordNo() { var newCsvFile = (CsvFile)m_ValidSetting.Clone(); newCsvFile.DisplayRecordNo = true; using (var test = new CsvFileReader(newCsvFile)) { test.Open(false, CancellationToken.None); var res = test.WriteToDataTable(newCsvFile, 0, null, CancellationToken.None); Assert.AreEqual(7, res.Rows.Count); Assert.AreEqual( 6 + (newCsvFile.DisplayStartLineNo ? 1 : 0) + (newCsvFile.DisplayEndLineNo ? 1 : 0) + (newCsvFile.DisplayRecordNo ? 1 : 0), res.Columns.Count); } }
public async Task GetDataTableAsync2() { using (var processDisplay = new CustomProcessDisplay(UnitTestInitializeCsv.Token)) { var test2 = (CsvFile)m_ValidSetting.Clone(); test2.RecordLimit = 4; using (var test = new CsvFileReader(test2, processDisplay)) { await test.OpenAsync(processDisplay.CancellationToken); var dt = await test.GetDataTableAsync(-1, false, false, false, false, false, null, processDisplay.CancellationToken); Assert.AreEqual(test2.RecordLimit, dt.Rows.Count); } } }