/* Documentation and examples for using ADO.NET: * http://msdn.microsoft.com/en-us/library/e80y5yhx%28v=VS.80%29.aspx */ public static void testcase() { Console.WriteLine("Test cases execution started..."); Console.WriteLine(); TestCasesOld.Run(TestCasesOld.Test_Demo_Basic); TestCasesOld.Run(TestCasesOld.Test_Parameters); TestCasesOld.Run(TestCasesOld.Test_Various_DataTypes); Console.WriteLine(); Console.WriteLine(String.Format("*** Test cases results ***")); Console.WriteLine(String.Format("{0} test case(s) analyzed.", testCasesCount)); Console.WriteLine(String.Format("{0} test case(s) executed.", executed)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(String.Format("{0} test case(s) passed.", passed)); if (executed - passed > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(String.Format("{0} test case(s) failed.", executed - passed)); Console.WriteLine("The following test cases have failed:"); foreach (string failedTestCase in failedTestCases) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(String.Format("\t{0}", failedTestCase)); } } Console.ResetColor(); Console.WriteLine(); }
public void TestMethodOld() { // // TODO: Add test logic here // //return; TestCasesOld.testcase(); }
private static void Run(Action f) { bool testPassed = false; string testCaseName; try { TestCasesOld.SuiteSetup(); testCaseName = f.Method.ToString().Replace("Void ", "").Replace("()", ""); if (testCaseName.StartsWith("Test_")) { testCasesCount++; } foreach (string regexFilter in TestCasesOld.runFilters) { Match match = Regex.Match(testCaseName, regexFilter, RegexOptions.IgnoreCase); if (match.Success && (TestCasesOld.matchExactName == false || (TestCasesOld.matchExactName && testCaseName == regexFilter))) { Console.WriteLine("Executing: [" + testCaseName + "]" + "..."); executed++; try { TestCasesOld.TestSetup(); f(); TestCasesOld.TestCleanup(); passed++; testPassed = true; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Details: " + ex.StackTrace); } break; //exit foreach, as test case name might match multiple filters } else { //Console.WriteLine("Skipped: [" + testCaseName + "]"); } } } finally { TestCasesOld.SuiteCleanup(); } if (!testPassed) { failedTestCases.Add(testCaseName); } }
private static void CleanupTestTableLOB(OleDbConnection conn) { TestCasesOld.ExecuteSQL("drop table if exists t", conn); }
private static void CreateTestTableLOB(OleDbConnection conn) { TestCasesOld.ExecuteSQL("drop table if exists t", conn); TestCasesOld.ExecuteSQL("create table t(b BLOB, c CLOB)", conn); }
private static void CreateTestTable(OleDbConnection conn) { TestCasesOld.ExecuteSQL("drop table if exists t", conn); TestCasesOld.ExecuteSQL("create table t(a int, b char(10), c string, d float, e double, f date)", conn); }
/// <summary> /// Test CUBRID data types Get...() /// </summary> private static void Test_Various_DataTypes() { using (OleDbConnection conn = new OleDbConnection()) { conn.ConnectionString = TestCasesOld.connString; conn.Open(); TestCasesOld.ExecuteSQL("drop table if exists t", conn); string sql = "create table t("; sql += "c_integer_ai integer AUTO_INCREMENT, "; sql += "c_smallint smallint, "; sql += "c_integer integer, "; sql += "c_bigint bigint, "; sql += "c_numeric numeric(15,1), "; sql += "c_float float, "; sql += "c_decimal decimal(15,3), "; sql += "c_double double, "; sql += "c_char char, "; sql += "c_varchar varchar(4096), "; sql += "c_time time, "; sql += "c_date date, "; sql += "c_timestamp timestamp, "; sql += "c_datetime datetime, "; sql += "c_bit bit(1), "; sql += "c_varbit bit varying(4096), "; sql += "c_monetary monetary, "; sql += "c_string string"; sql += ")"; TestCasesOld.ExecuteSQL(sql, conn); sql = "insert into t values("; sql += "1, "; sql += "11, "; sql += "111, "; sql += "1111, "; sql += "1.1, "; sql += "1.11, "; sql += "1.111, "; sql += "1.1111, "; sql += "'a', "; sql += "'abcdfghijk', "; sql += "TIME '13:15:45 pm', "; sql += "DATE '00-10-31', "; sql += "TIMESTAMP '13:15:45 10/31/2008', "; sql += "DATETIME '13:15:45 10/31/2008', "; sql += "B'0', "; sql += "B'0', "; sql += "123456789, "; sql += "'qwerty'"; sql += ")"; TestCasesOld.ExecuteSQL(sql, conn); sql = "select * from t"; using (OleDbCommand cmd = new OleDbCommand(sql, conn)) { try { OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) //only one row will be available { Debug.Assert(reader.GetInt32(0) == 1); Debug.Assert(reader.GetInt16(1) == 11); Debug.Assert(reader.GetInt32(2) == 111); Debug.Assert(reader.GetInt64(3) == 1111); Debug.Assert(reader.GetDecimal(4) == (decimal)1.1); Debug.Assert(reader.GetFloat(5) == (float)1.11); //"Single" Debug.Assert(reader.GetDecimal(6) == (decimal)1.111); Debug.Assert(reader.GetDouble(7) == (double)1.1111); //We use GetString() because GetChar() is not supported or System.Data.OleDb. //http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdatareader.getchar Debug.Assert(reader.GetString(8) == "a"); //"String" ("Char" in CUBRID) Debug.Assert(reader.GetString(9) == "abcdfghijk"); //"String" ("String in CUBRID) //GetGateTime cannot cast just the time value in a DateTime object, so we use TimeSpan Debug.Assert(reader.GetTimeSpan(10) == new TimeSpan(13, 15, 45)); //"TimeSpan" Debug.Assert(reader.GetDateTime(11) == new DateTime(2000, 10, 31)); //"DateTime" Debug.Assert(reader.GetDateTime(12) == new DateTime(2008, 10, 31, 13, 15, 45)); //"DateTime" Console.WriteLine(reader.GetValue(13)); Debug.Assert(reader.GetDateTime(13) == new DateTime(2008, 10, 31, 13, 15, 45)); //"DateTime" //The GetByte() method does not perform any conversions and the driver does not give tha data as Byte //http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdatareader.getbyte //Use GetValue() or GetBytes() methods to retrieve BIT coulumn value // Debug.Assert((reader.GetValue(14) as byte[])[0] == (byte)0); //"Byte[]" ("bit(1)" in CUBRID) //Or Byte[] value = new Byte[1]; reader.GetBytes(14, 0, value, 0, 1); // Debug.Assert(value[0] == (byte)0);//"Byte[]" ("bit(1)" in CUBRID) //Debug.Assert((reader.GetValue(14) as byte[])[0] == (byte)0); //"Byte[]" ("bit varying(4096)" in CUBRID) //Or // reader.GetBytes(15, 0, value, 0, 1); // Debug.Assert(value[0] == (byte)0);//"Byte[]" ("bit varying(4096)" in CUBRID) Debug.Assert(reader.GetDouble(16) == 123456789.0); //"Double" ("Monetary" in CUBRID) Debug.Assert(reader.GetString(17) == "qwerty"); //"String" } } catch (Exception ex) { Console.WriteLine(ex.Message); } } TestCasesOld.ExecuteSQL("drop table if exists t", conn); } }