public void TestGuesser_IntAnddecimal_MustUsedecimalThenString() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("15"); t.AdjustToCompensateForValue("29.9"); t.AdjustToCompensateForValue("200"); t.AdjustToCompensateForValue(null); t.AdjustToCompensateForValue(DBNull.Value); Assert.AreEqual("decimal(4,1)", t.GetSqlDBType(_translater)); t.AdjustToCompensateForValue("D"); Assert.AreEqual("varchar(5)", t.GetSqlDBType(_translater)); }
public void TestGuesser_IntFloatString() { MicrosoftSQLTypeTranslater tt = new MicrosoftSQLTypeTranslater(); Guesser t = new Guesser(); t.AdjustToCompensateForValue("-1000"); Assert.AreEqual("int", t.GetSqlDBType(tt)); t.AdjustToCompensateForValue("1.1"); Assert.AreEqual("decimal(5,1)", t.GetSqlDBType(tt)); t.AdjustToCompensateForValue("A"); Assert.AreEqual("varchar(6)", t.GetSqlDBType(tt)); }
public void TestGuesser_TimeObject() { Guesser t = new Guesser(); t.AdjustToCompensateForValue(new TimeSpan(10, 1, 1)); Assert.AreEqual(typeof(TimeSpan), t.Guess.CSharpType); Assert.AreEqual("time", t.GetSqlDBType(_translater)); }
public void TestGuesser_Midnight() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("00:00"); Assert.AreEqual(typeof(TimeSpan), t.Guess.CSharpType); Assert.AreEqual("time", t.GetSqlDBType(_translater)); }
public void TestGuesser_TimeNoSeconds() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("12:01"); Assert.AreEqual(typeof(TimeSpan), t.Guess.CSharpType); Assert.AreEqual("time", t.GetSqlDBType(_translater)); }
public void TestGuesser_FallbackOntoVarcharFromFloat() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("15.5"); t.AdjustToCompensateForValue("F"); Assert.AreEqual(typeof(string), t.Guess.CSharpType); Assert.AreEqual("varchar(4)", t.GetSqlDBType(_translater)); }
public void TestGuesser_Negatives() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("-1"); t.AdjustToCompensateForValue("-99.99"); Assert.AreEqual(t.Guess.CSharpType, typeof(decimal)); Assert.AreEqual("decimal(4,2)", t.GetSqlDBType(_translater)); }
public void TestGuesser_DateTime_EnglishWithTimeAndAM() { Guesser t = new Guesser(); t.AdjustToCompensateForValue(GetCultureSpecificDate() + " 11:10AM"); t.AdjustToCompensateForValue(null); Assert.AreEqual(t.Guess.CSharpType, typeof(DateTime)); Assert.AreEqual("datetime2", t.GetSqlDBType(_translater)); }
public void TestGuesser_DateTime() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("01/01/2001"); t.AdjustToCompensateForValue(null); Assert.AreEqual(t.Guess.CSharpType, typeof(DateTime)); Assert.AreEqual("datetime2", t.GetSqlDBType(_translater)); }
public void TestGuesser_MixedDateAndTime_FallbackToString() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("09:01"); Assert.AreEqual(typeof(TimeSpan), t.Guess.CSharpType); t.AdjustToCompensateForValue("2001-12-29 23:01"); Assert.AreEqual(typeof(string), t.Guess.CSharpType); Assert.AreEqual("varchar(16)", t.GetSqlDBType(_translater)); }
public void TestGuesser_DateTime_EnglishWithTime() { Guesser t = new Guesser(); Console.WriteLine(CultureInfo.CurrentCulture.EnglishName); Console.WriteLine(CultureInfo.CurrentCulture.DateTimeFormat.MonthDayPattern); t.AdjustToCompensateForValue(GetCultureSpecificDate() + " 11:10"); t.AdjustToCompensateForValue(null); Assert.AreEqual(t.Guess.CSharpType, typeof(DateTime)); Assert.AreEqual("datetime2", t.GetSqlDBType(_translater)); }
public void TestGuesser_IntAnddecimal_MustUsedecimal() { Guesser t = new Guesser(); t.AdjustToCompensateForValue("15"); t.AdjustToCompensateForValue("29.9"); t.AdjustToCompensateForValue("200"); t.AdjustToCompensateForValue(null); t.AdjustToCompensateForValue(DBNull.Value); Assert.AreEqual(t.Guess.CSharpType, typeof(decimal)); var sqlType = t.GetSqlDBType(_translater); Assert.AreEqual("decimal(4,1)", sqlType); var orig = t.Guess; var reverseEngineered = _translater.GetDataTypeRequestForSQLDBType(sqlType); Assert.AreEqual(orig, reverseEngineered, "The computed DataTypeRequest was not the same after going via sql datatype and reverse engineering"); }