public void CheckInsert (TestCaseResult result) { DropTable (); CreateTable (); InsertRow (0); InsertRow (1); InsertRow (2); CheckTable (result); }
public void RollbackNoWork (TestCaseResult result) { CheckTransactionCapable (result); CheckTable (result); VirtuosoTransaction t = connection.BeginTransaction (); result.FailIfNotSame (connection, t.Connection); t.Rollback (); CheckTable (result); }
public void RunCase(TestCaseResult result) { SetUp(); try { PerformTest(result); } finally { TearDown(); } }
public void TestGetString (TestCaseResult result) { InsertRowText (); VirtuosoCommand cmd = connection.CreateCommand (); cmd.CommandText = "select data from xmlt"; VirtuosoDataReader rdr = cmd.ExecuteReader (); rdr.Read (); String x = rdr.GetString (0); FailIfXmlNotEqual (result, x, TheXml); }
public override void EndTest (TestCase testCase, TestCaseResult result) { if (result.HasSkipped ()) Console.WriteLine ("SKIPPED: {0}", testCase.Name); else if (result.HasPassed ()) Console.WriteLine ("PASSED: {0}", testCase.Name); #if false else if (result.HasWarnings ()) Console.WriteLine ("PASSED with warnings: {0}", testCase.Name); #endif else Console.WriteLine ("***FAILED: {0}", testCase.Name); }
public void DelayLessThanTimeout (TestCaseResult result) { VirtuosoCommand command = connection.CreateCommand (); try { command.CommandTimeout = 50; command.CommandText = "delay(5)"; command.ExecuteNonQuery (); } finally { command.Dispose (); } }
public void TestGetValue (TestCaseResult result) { InsertRowText (); VirtuosoCommand cmd = connection.CreateCommand (); cmd.CommandText = "select data from xmlt"; VirtuosoDataReader rdr = cmd.ExecuteReader (); rdr.Read (); object obj = rdr.GetValue (0); result.FailIfNotEqual (typeof (SqlXml).Name, obj.GetType().Name); SqlXml x = (SqlXml) obj; FailIfXmlNotEqual (result, x.ToString (), TheXml); }
private void EndTest(TestCase testCase, TestCaseResult testCaseResult) { lock (listeners.SyncRoot) { if (testCaseResult.HasPassed()) { passedCount++; } foreach (ITestListener listener in listeners) { listener.EndTest(testCase, testCaseResult); } } }
public void DeriveParamters (TestCaseResult result) { DropProcedure (); ExecuteNonQuery ( "create function BAR (in X integer, out Y integer, inout Z integer, in V varchar(20), in W nvarchar(20), in D numeric(20, 5)) returns real\n" + "{\n" + " return 0.0;\n" + "}\n" ); VirtuosoCommand command = connection.CreateCommand (); command.CommandType = CommandType.StoredProcedure; command.CommandText = "BAR"; try { VirtuosoCommandBuilder.DeriveParameters (command); result.FailIfNotEqual ("Parameter Count", 7, command.Parameters.Count); CheckParameter (result, command.Parameters[0], "ReturnValue", ParameterDirection.ReturnValue, VirtDbType.Real, DbType.Single, 4, 0, 0); // FIXME: The precision should be 7. CheckParameter (result, command.Parameters[1], "X", ParameterDirection.Input, VirtDbType.Integer, DbType.Int32, 4, 10, 0); CheckParameter (result, command.Parameters[2], "Y", ParameterDirection.Output, VirtDbType.Integer, DbType.Int32, 4, 10, 0); CheckParameter (result, command.Parameters[3], "Z", ParameterDirection.InputOutput, VirtDbType.Integer, DbType.Int32, 4, 10, 0); CheckParameter (result, command.Parameters[4], "V", ParameterDirection.Input, VirtDbType.VarChar, DbType.AnsiString, 20, 0, 0); CheckParameter (result, command.Parameters[5], "W", ParameterDirection.Input, VirtDbType.NVarChar, DbType.String, 20, 0, 0); CheckParameter (result, command.Parameters[6], "D", ParameterDirection.Input, VirtDbType.Decimal, DbType.Decimal, 19, 20, 5); } finally { command.Dispose (); } }
public void State (TestCaseResult result) { string host = TestSettings.GetString ("HOST"); string connectionString = "HOST=" + host + ";UID=dba;PWD=dba;"; VirtuosoConnection conn = new VirtuosoConnection (connectionString); try { result.FailIfNotEqual (ConnectionState.Closed, conn.State); conn.Open (); result.FailIfNotEqual (ConnectionState.Open, conn.State); conn.Close (); result.FailIfNotEqual (ConnectionState.Closed, conn.State); } finally { conn.Dispose (); } }
public void DisposeInvalid (TestCaseResult result) { VirtuosoConnection conn = null; try { string connectionString = "InvalidConnectionString"; conn = new VirtuosoConnection (connectionString); } catch (ArgumentException) { // suppress ArgumentException } finally { if (conn != null) conn.Dispose (); } }
private void CheckParameter ( TestCaseResult result, VirtuosoParameter parameter, string parameterName, ParameterDirection direction, VirtDbType vdbType, DbType dbType, int size, byte precision, byte scale) { result.FailIfNotEqual (this, "ParameterName", parameterName, parameter.ParameterName); result.FailIfNotEqual (this, parameterName + ".Direction", direction, parameter.Direction); result.FailIfNotEqual (this, parameterName + ".VirtDbType", vdbType, parameter.VirtDbType); result.FailIfNotEqual (this, parameterName + ".DbType", dbType, parameter.DbType); result.FailIfNotEqual (this, parameterName + ".Size", size, parameter.Size); result.FailIfNotEqual (this, parameterName + ".Precision", precision, parameter.Precision); result.FailIfNotEqual (this, parameterName + ".Scale", scale, parameter.Scale); }
public void DelayMoreThanTimeout (TestCaseResult result) { VirtuosoCommand command = connection.CreateCommand (); bool thrown = false; try { command.CommandTimeout = 5; command.CommandText = "delay(50)"; command.ExecuteNonQuery (); } catch (SystemException) { thrown = true; } finally { command.Dispose (); } result.FailIfNot ("No timeout exception is thrown", thrown); }
public void GetMethods (TestCaseResult result) { DropTable (); CreateTable (); DataSet dataset = new DataSet (); VirtuosoDataAdapter adapter = null; VirtuosoCommandBuilder builder = null; try { adapter = new VirtuosoDataAdapter (); adapter.SelectCommand = new VirtuosoCommand ("select * from foo", connection); adapter.Fill (dataset, "table"); builder = new VirtuosoCommandBuilder (); builder.DataAdapter = adapter; VirtuosoCommand delete = builder.GetDeleteCommand (); VirtuosoCommand insert = builder.GetInsertCommand (); VirtuosoCommand update = builder.GetUpdateCommand (); // dummy thing to evade the delete,insert,update not used warnings if (delete != null || insert != null || update != null) adapter = null; } finally { if (builder != null) { builder.Dispose (); builder = null; } if (adapter != null) { adapter.Dispose (); adapter = null; } } }
public void TestGetCharsDefaultNChar (TestCaseResult result) { DoGetDataTest (result, "select nc from foo order by id", 0, CommandBehavior.Default, Selector.GetChars, Sequence.GetAll); }
public void TestDataSetTable (TestCaseResult result) { CheckDataSetTable (result); }
private void CompareData (TestCaseResult result, int row, int column, char[] data, long length, long offset) { DataRow dataRow = checkTable.Rows[row]; char[] chars = dataRow[column].ToString().ToCharArray(); char[] expected = new char[length]; char[] actual = new char[length]; Array.Copy (chars, (int) offset, expected, 0, (int) length); Array.Copy (data, 0, actual, 0, (int) length); result.FailIfNotEqual (this, expected, actual); }
private void CompareData (TestCaseResult result, int row, int column, byte[] data, long length, long offset) { DataRow dataRow = checkTable.Rows[row]; byte[] bytes = (byte[]) dataRow[column]; byte[] expected = new byte[length]; byte[] actual = new byte[length]; Array.Copy (bytes, (int) offset, expected, 0, (int) length); Array.Copy (data, 0, actual, 0, (int) length); result.FailIfNotEqual (this, expected, actual); }
public void RunCase (TestCaseResult result) { SetUp (); try { PerformTest (result); } finally { TearDown (); } }
public void ResultSetAndOutputParameters (TestCaseResult result) { DropProcedure (); DropProcedure (); ExecuteNonQuery ( "create procedure bar (out x integer)\n" + "{\n" + " declare i int;\n" + " result_names (i);\n" + " result (1);\n" + " result (2);\n" + " x := 3;\n" + " return 4;\n" + "}\n" ); VirtuosoCommand command = connection.CreateCommand (); command.CommandType = CommandType.StoredProcedure; command.CommandText = "bar"; VirtuosoParameter returnValue = command.CreateParameter (); returnValue.ParameterName = "ReturnValue"; returnValue.Direction = ParameterDirection.ReturnValue; returnValue.VirtDbType = VirtDbType.Integer; command.Parameters.Add (returnValue); VirtuosoParameter x = command.CreateParameter (); x.ParameterName = "x"; x.Direction = ParameterDirection.Output; x.VirtDbType = VirtDbType.Integer; command.Parameters.Add (x); VirtuosoDataReader reader = null; bool closed = false; try { reader = command.ExecuteReader (); result.FailIfNotEqual (1, reader.FieldCount); result.FailIfNotEqual ("i", reader.GetName (0).ToLower ()); result.FailIfNotEqual (typeof (int), reader.GetFieldType (0)); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual (1, reader["i"]); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual (2, reader["i"]); result.FailIfNotEqual (false, reader.Read ()); reader.Close (); closed = true; result.FailIfNotEqual ("Out Parameter", 3, x.Value); result.FailIfNotEqual ("Return Value", 4, returnValue.Value); } finally { if (reader != null && !closed) reader.Close (); command.Dispose (); } }
public void GetMethods (TestCaseResult result) { WriteCommand ("builder.GetDeleteCommand ():", builder.GetDeleteCommand ()); WriteCommand ("builder.GetInsertCommand ():", builder.GetInsertCommand ()); WriteCommand ("builder.GetUpdateCommand ():", builder.GetUpdateCommand ()); }
public void OutputParameters (TestCaseResult result) { DropProcedure (); ExecuteNonQuery ( "create procedure bar (in x integer, out y integer, inout z integer)\n" + "{\n" + " y := x * 2;\n" + " z := z * 2;\n" + " return y + z;\n" + "}\n" ); VirtuosoCommand command = connection.CreateCommand (); command.CommandType = CommandType.StoredProcedure; command.CommandText = "bar"; VirtuosoParameter returnValue = command.CreateParameter (); returnValue.ParameterName = "ReturnValue"; returnValue.Direction = ParameterDirection.ReturnValue; returnValue.VirtDbType = VirtDbType.Integer; command.Parameters.Add (returnValue); VirtuosoParameter x = command.CreateParameter (); x.ParameterName = "x"; x.Direction = ParameterDirection.Input; x.VirtDbType = VirtDbType.Integer; x.Value = 2; command.Parameters.Add (x); VirtuosoParameter y = command.CreateParameter (); y.ParameterName = "y"; y.Direction = ParameterDirection.Output; y.VirtDbType = VirtDbType.Integer; command.Parameters.Add (y); VirtuosoParameter z = command.CreateParameter (); z.ParameterName = "z"; z.Direction = ParameterDirection.InputOutput; z.VirtDbType = VirtDbType.Integer; z.Value = 3; command.Parameters.Add (z); try { command.ExecuteNonQuery (); result.FailIfNotEqual (this, "Return Value", 10, returnValue.Value); result.FailIfNotEqual (this, "Out Parameter", 4, y.Value); result.FailIfNotEqual (this, "InOut Parameter", 6, z.Value); } finally { command.Dispose (); } }
public void Run(TestResult testResult) { TestCaseResult testCaseResult = CreateTestCaseResult(testResult); testResult.RunCase(this, testCaseResult); }
public void TestGetCharsSequentialNCharSkip (TestCaseResult result) { DoGetDataTest (result, "select nc from foo order by id", 0, CommandBehavior.SequentialAccess, Selector.GetChars, Sequence.GetHalf); }
public void DisposeNewCommand (TestCaseResult result) { VirtuosoCommand command = connection.CreateCommand (); command.Dispose (); }
public void TableUpdate (TestCaseResult result) { DropTable (); CreateTable (); InsertRow (1); InsertRow (2); DataSet dataset = new DataSet (); VirtuosoDataAdapter adapter = null; VirtuosoCommandBuilder builder = null; try { adapter = new VirtuosoDataAdapter (); adapter.SelectCommand = new VirtuosoCommand ("select * from foo", connection); adapter.Fill (dataset, "table"); builder = new VirtuosoCommandBuilder (); builder.DataAdapter = adapter; DataTable table = dataset.Tables["table"]; if (table.Rows.Count > 0) { DataRow row = table.Rows[0]; row.Delete (); } //if (table.Rows.Count > 1) //{ // DataRow row = table.Rows[1]; // row["j"] = 555; // row["s"] = "bbb"; //} DataRow newrow = table.NewRow (); newrow["i"] = 3; newrow["n"] = 333; table.Rows.Add (newrow); adapter.Update (dataset, "Table"); } finally { if (builder != null) { builder.Dispose (); builder = null; } if (adapter != null) { adapter.Dispose (); adapter = null; } } }
public void RunCase(TestCase testCase, TestCaseResult testCaseResult) { StartTest(testCase); testCaseResult.RunCase(testCase); EndTest(testCase, testCaseResult); }
private void CheckDataSetTable (TestCaseResult result) { VirtuosoCommand select = connection.CreateCommand (); select.CommandText = "select * from foo order by id"; VirtuosoDataAdapter adapter = new VirtuosoDataAdapter (); adapter.SelectCommand = (VirtuosoCommand) select; DataSet dataset = new DataSet (); adapter.Fill (dataset); DataTable table = dataset.Tables["table"]; result.FailIfNotEqual (checkTable.Rows.Count, table.Rows.Count); result.FailIfNotEqual (checkTable.Columns.Count, table.Columns.Count); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; DataRow checkRow = checkTable.Rows[i]; for (int j = 0; j < table.Columns.Count; j++) { string name = table.Columns[j].ColumnName; result.FailIfNotEqual (this, "Comparison failed for column " + name + ": ", checkRow[name], row[name]); } } }
public void MultipleResultSets (TestCaseResult result) { DropProcedure (); ExecuteNonQuery ( "create procedure bar ()\n" + "{\n" + " declare i int;\n" + " declare c char;\n" + " result_names (i);\n" + " result (1);\n" + " result (2);\n" + " end_result ();\n" + " result_names (c);\n" + " result ('a');\n" + " result ('b');\n" + " return 0;\n" + "}\n" ); VirtuosoCommand command = connection.CreateCommand (); command.CommandType = CommandType.StoredProcedure; command.CommandText = "bar"; VirtuosoDataReader reader = null; try { reader = command.ExecuteReader (); result.FailIfNotEqual (1, reader.FieldCount); result.FailIfNotEqual ("i", reader.GetName (0).ToLower ()); result.FailIfNotEqual (typeof (int), reader.GetFieldType (0)); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual (1, reader["i"]); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual (2, reader["i"]); result.FailIfNotEqual (false, reader.Read ()); result.FailIfNotEqual (true, reader.NextResult ()); result.FailIfNotEqual (1, reader.FieldCount); result.FailIfNotEqual ("c", reader.GetName (0).ToLower ()); result.FailIfNotEqual (typeof (string), reader.GetFieldType (0)); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual ("a", reader["c"]); result.FailIfNotEqual (true, reader.Read ()); result.FailIfNotEqual ("b", reader["c"]); result.FailIfNotEqual (false, reader.NextResult ()); } finally { if (reader != null) reader.Close (); command.Dispose (); } }
public void RowUpdatingHandler (TestCaseResult result) { WriteCommand ("SelectCommand", adapter.SelectCommand); DataSet dataset = new DataSet (); adapter.Fill (dataset, "table"); DataTable table = dataset.Tables["table"]; if (table.Rows.Count > 0) { DataRow row = table.Rows[0]; row.Delete (); } if (table.Rows.Count > 1) { DataRow row = table.Rows[1]; row["j"] = 555; row["s"] = "bbb"; } DataRow newrow = table.NewRow (); newrow["i"] = 3; newrow["n"] = 333; table.Rows.Add (newrow); adapter.Update (dataset, "table"); }
private void DoGetDataTest (TestCaseResult result, string text, int column, CommandBehavior behavior, Selector selector, Sequence sequence) { VirtuosoCommand cmd = null; VirtuosoDataReader dr = null; try { cmd = new VirtuosoCommand (text, connection); dr = cmd.ExecuteReader (behavior); CheckGetData (result, dr, column, selector, sequence); } finally { if (dr != null) dr.Close (); if (cmd != null) cmd.Dispose (); } }
protected override void PerformTest(TestCaseResult result) { result.Fail(message); }
private void CheckGetData (TestCaseResult result, VirtuosoDataReader dr, int column, Selector selector, Sequence sequence) { string name = dr.GetName (column); int tableColumn = checkTable.Columns.IndexOf (name); for (int row = 0; dr.Read (); row++) { //if (dr.IsDBNull (column)) if (row == 0) continue; long length; if (selector == Selector.GetBytes) length = dr.GetBytes (column, 0, null, 0, 0); else //if (selector == Selector.GetChars) length = dr.GetChars (column, 0, null, 0, 0); //Console.WriteLine ("row: {0}", row); //Console.WriteLine ("length: {0}", length); CompareSize (result, row, tableColumn, selector, length, 0); long offset = 0; byte[] bytes = new byte[BufferSize]; char[] chars = new char[BufferSize]; int count = 0; while (offset < length) { //Console.WriteLine ("offset: {0}", offset); long nextLength; if (selector == Selector.GetBytes) { for (int i = 0; i < bytes.Length; i++) bytes[i] = 0; nextLength = dr.GetBytes (column, offset, bytes, 0, bytes.Length); } else //if (selector == Selector.GetChars) { for (int i = 0; i < chars.Length; i++) chars[i] = (char) 0; nextLength = dr.GetChars (column, offset, chars, 0, chars.Length); } result.FailIfEqual (this, 0, nextLength); if (offset + nextLength < length) result.FailIfNotEqual (this, (long) BufferSize, nextLength); else result.FailIfNotEqual (this, (long) (length - offset), nextLength); if (selector == Selector.GetBytes) CompareData (result, row, tableColumn, bytes, nextLength, offset); else //if (selector == Selector.GetChars) CompareData (result, row, tableColumn, chars, nextLength, offset); if (sequence == Sequence.GetAll) { offset += nextLength; } else if (sequence == Sequence.GetHalf) { offset += 2 * nextLength; } else //if (sequence == Sequence.GetTwice) { count++; if (count == 2) { count = 0; offset += 2 * nextLength; } } } } }
public void TestGetCharsSequentialBinTwice (TestCaseResult result) { DoGetDataTest (result, "select b from foo order by id", 0, CommandBehavior.SequentialAccess, Selector.GetBytes, Sequence.GetTwice); }
private void CompareSize (TestCaseResult result, int row, int column, Selector selector, long length, long offset) { DataRow dataRow = checkTable.Rows[row]; object columnData = dataRow[column]; if (selector == Selector.GetBytes) { byte[] bytes = (byte[]) columnData; if (offset > bytes.Length) result.FailIfNotEqual (this, 0, length); else result.FailIfNotEqual (this, bytes.Length - offset, length); } if (selector == Selector.GetChars) { char[] chars = columnData.ToString().ToCharArray(); if (offset > chars.Length) result.FailIfNotEqual (this, 0, length); else result.FailIfNotEqual (this, chars.Length - offset, length); } /* if (selector == Selector.GetValue) { throw new NotSupportedException (); } */ }