public void CanDetectDecimalWithZeros() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("sv-se"); var result = new CsvColumnAnalyzer("1,000"); Assert.IsTrue(result.DataType == ColumnType.Decimal); }
public void CanDetectLocalCurrency() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("sv-se"); var x = new CsvColumnAnalyzer("12,34 kr"); Assert.IsTrue(x.DataType == ColumnType.Decimal); }
private string ToLocalType(CsvColumnAnalyzer column) { switch (column.DataType) { case ColumnType.Empty: return("bit"); case ColumnType.Integer: if (column.MinInteger >= 0) { if (column.MaxInteger <= 1) { return("bit"); } if (column.MaxInteger < 256) { return("tinyint"); } } if (column.MinInteger >= -32768 && column.MaxInteger <= 32767) { return("tinyint"); } else if (column.MinInteger >= -2147483648 && column.MaxInteger <= 2147483647) { return("int"); } else { return("bigint"); } case ColumnType.Decimal: return("float"); case ColumnType.String: return("NVARCHAR(" + column.MaxSize + ")"); default: throw new ArgumentOutOfRangeException(); } }