public void FillGuessColumnFormatDateParts() { var setting = new CsvFile { FileName = Path.Combine(m_ApplicationDirectory, "Sessions.txt"), HasFieldHeader = true, ByteOrderMark = true }; setting.FileFormat.FieldDelimiter = "\t"; ApplicationSetting.FillGuessSettings.DateParts = true; using (var prc = new DummyProcessDisplay()) { setting.FillGuessColumnFormatReader(false, prc); } ApplicationSetting.FillGuessSettings.DateParts = false; Assert.AreEqual("Start Date", setting.Column[0].Name, "Column 1 Start date"); Assert.AreEqual("Start Time", setting.Column[1].Name, "Column 2 Start Time"); Assert.AreEqual("Start Time", setting.Column[0].TimePart, "TimePart is Start Time"); Assert.AreEqual(DataType.DateTime, setting.Column[0].DataType); Assert.AreEqual("MM/dd/yyyy", setting.Column[0].DateFormat); Assert.AreEqual("HH:mm:ss", setting.Column[1].DateFormat); }
public void FillGuessColumnFormatGermanDateAndNumbers() { var setting = new CsvFile { FileName = Path.Combine(m_ApplicationDirectory, "DateAndNumber.csv"), HasFieldHeader = true }; setting.FileFormat.FieldQualifier = "Quote"; setting.CodePageId = 1252; setting.FileFormat.FieldDelimiter = "TAB"; // setting.TreatTextNullAsNull = true; using (var processDisplay = new DummyProcessDisplay()) { setting.FillGuessColumnFormatReader(false, processDisplay); } Assert.IsNotNull(setting.GetColumn(@"Betrag Brutto (2 Nachkommastellen)"), "Data Type recognized"); Assert.AreEqual(DataType.Numeric, setting.GetColumn(@"Betrag Brutto (2 Nachkommastellen)").DataType, "Is Numeric"); Assert.AreEqual(",", setting.GetColumn(@"Betrag Brutto (2 Nachkommastellen)").DecimalSeparator, "Decimal Separator found"); Assert.AreEqual(DataType.DateTime, setting.GetColumn(@"Erstelldatum Rechnung").DataType); }
public void FillGuessColumnFormatDoNotIgnoreID() { var setting = new CsvFile { FileName = Path.Combine(m_ApplicationDirectory, "BasicCSV.txt") }; setting.FileFormat.FieldDelimiter = ","; setting.HasFieldHeader = true; // setting.TreatTextNullAsNull = true; ApplicationSetting.FillGuessSettings.IgnoreIdColums = false; using (var processDisplay = new DummyProcessDisplay()) { setting.FillGuessColumnFormatReader(false, processDisplay); Assert.AreEqual(DataType.Integer, setting.GetColumn("ID").DataType); Assert.AreEqual(DataType.DateTime, setting.GetColumn("ExamDate").DataType); Assert.AreEqual(DataType.Boolean, setting.GetColumn("IsNativeLang").DataType); } }
public void FillGuessColumnFormatTrailingColumns() { var setting = new CsvFile { FileName = Path.Combine(m_ApplicationDirectory, "Test.csv"), HasFieldHeader = true, ByteOrderMark = true }; setting.FileFormat.FieldDelimiter = ","; setting.SkipRows = 1; using (var processDisplay = new DummyProcessDisplay()) { setting.FillGuessColumnFormatReader(false, processDisplay); } Assert.AreEqual(DataType.DateTime, setting.Column[2].DataType, "column2"); Assert.AreEqual(DataType.DateTime, setting.Column[3].DataType, "column3"); Assert.AreEqual(DataType.DateTime, setting.Column[4].DataType, "column4"); }
public void FillGuessColumnFormatTextColumns() { var setting = new CsvFile { FileName = Path.Combine(m_ApplicationDirectory, "Test.csv"), HasFieldHeader = true, ByteOrderMark = true }; setting.FileFormat.FieldDelimiter = ","; setting.SkipRows = 1; using (var processDisplay = new DummyProcessDisplay()) { setting.FillGuessColumnFormatReader(true, processDisplay); } Assert.AreEqual(11, setting.Column.Count); Assert.AreEqual(DataType.DateTime, setting.Column[7].DataType); Assert.AreEqual(DataType.DateTime, setting.Column[8].DataType); Assert.AreEqual(DataType.DateTime, setting.Column[9].DataType); Assert.AreEqual(DataType.String, setting.Column[10].DataType); }