Thread: [pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source PgBaseTest.cs,1.5
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-10-25 21:03:50
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source In directory sc8-pr-cvs1:/tmp/cvs-serv21381 Modified Files: PgBaseTest.cs PgCommandBuilderTest.cs Log Message: Added changes for allow future testing of geometic types Index: PgBaseTest.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source/PgBaseTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PgBaseTest.cs 20 Sep 2003 10:47:30 -0000 1.5 --- PgBaseTest.cs 25 Oct 2003 20:57:49 -0000 1.6 *************** *** 133,136 **** --- 133,137 ---- StringBuilder commandText = new StringBuilder(); + // Table for general purpouse tests commandText.Append("CREATE TABLE public.test_table("); commandText.Append("int4_field int4 NOT NULL,"); *************** *** 147,155 **** commandText.Append("int8_field int8,"); commandText.Append("money_field money,"); ! commandText.Append("numeric_field numeric(8,2),"); commandText.Append("int2_array int2[],"); commandText.Append("int4_array int4[],"); commandText.Append("int8_array int8[],"); commandText.Append("serial_field serial NOT NULL,"); commandText.Append("CONSTRAINT test_table_pkey PRIMARY KEY (int4_field)"); commandText.Append(") WITH OIDS;"); --- 148,161 ---- commandText.Append("int8_field int8,"); commandText.Append("money_field money,"); ! commandText.Append("numeric_field numeric(8,2),"); ! commandText.Append("bool_array bool[],"); commandText.Append("int2_array int2[],"); commandText.Append("int4_array int4[],"); commandText.Append("int8_array int8[],"); + commandText.Append("mint2_array int2[][],"); commandText.Append("serial_field serial NOT NULL,"); + commandText.Append("macaddr_field macaddr,"); + commandText.Append("inet_field inet,"); + commandText.Append("name_field name,"); commandText.Append("CONSTRAINT test_table_pkey PRIMARY KEY (int4_field)"); commandText.Append(") WITH OIDS;"); *************** *** 157,160 **** --- 163,192 ---- PgCommand command = new PgCommand(commandText.ToString(), connection); command.ExecuteNonQuery(); + + commandText = new StringBuilder(); + + // Table for Geometric types tests + + commandText.Append("CREATE TABLE public.gemetric_test("); + commandText.Append("pk int4 NOT NULL,"); + commandText.Append("point_field point,"); + commandText.Append("point_array point[][],"); + commandText.Append("box_field box,"); + commandText.Append("box_array box[],"); + commandText.Append("line_field line,"); + commandText.Append("line_array line[],"); + commandText.Append("circle_field circle,"); + commandText.Append("circle_array circle[],"); + commandText.Append("polygon_field polygon,"); + commandText.Append("polygon_array polygon[],"); + commandText.Append("lseg_field lseg,"); + commandText.Append("lseg_array lseg[],"); + commandText.Append("path_field path,"); + commandText.Append("path_array path[],"); + commandText.Append("CONSTRAINT geometric_test_pkey PRIMARY KEY (pk)"); + commandText.Append(") WITH OIDS;"); + + command.CommandText = commandText.ToString(); + command.ExecuteNonQuery(); command.Dispose(); *************** *** 164,169 **** --- 196,221 ---- private void createFunctions() { + // Create language functions StringBuilder commandText = new StringBuilder(); + commandText.Append("CREATE OR REPLACE FUNCTION public.plpgsql_call_handler()"); + commandText.Append("RETURNS language_handler AS"); + commandText.Append("'$libdir/plpgsql', 'plpgsql_call_handler'"); + commandText.Append("LANGUAGE 'c' VOLATILE;"); + + PgCommand command = new PgCommand(commandText.ToString(), connection); + command.ExecuteNonQuery(); + + // Create languages + commandText = new StringBuilder(); + + commandText.Append("CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler;"); + + command = new PgCommand(commandText.ToString(), connection); + command.ExecuteNonQuery(); + + // Create test function public.TestCount() + commandText = new StringBuilder(); + commandText.Append("CREATE OR REPLACE FUNCTION public.TestCount()"); commandText.Append("RETURNS int8 AS"); *************** *** 173,180 **** commandText.Append("LANGUAGE 'sql' VOLATILE;"); ! PgCommand command = new PgCommand(commandText.ToString(), connection); command.ExecuteNonQuery(); commandText = new StringBuilder(); commandText.Append("CREATE OR REPLACE FUNCTION public.DeriveCount(int4)"); commandText.Append("RETURNS int8 AS"); --- 225,234 ---- commandText.Append("LANGUAGE 'sql' VOLATILE;"); ! command = new PgCommand(commandText.ToString(), connection); command.ExecuteNonQuery(); + // Create test function public.DeriveCount() commandText = new StringBuilder(); + commandText.Append("CREATE OR REPLACE FUNCTION public.DeriveCount(int4)"); commandText.Append("RETURNS int8 AS"); *************** *** 183,186 **** --- 237,262 ---- commandText.Append("'"); commandText.Append("LANGUAGE 'sql' VOLATILE;"); + + command.CommandText = commandText.ToString(); + command.ExecuteNonQuery(); + + // Create test function public.DeleteRows() + commandText = new StringBuilder(); + + commandText.Append("CREATE OR REPLACE FUNCTION public.DeleteRows(int4)\r\n"); + commandText.Append("RETURNS BOOLEAN AS '\r\n"); + commandText.Append("DECLARE\r\n"); + commandText.Append("\t\trows INTEGER;\r\n"); + commandText.Append("BEGIN\r\n"); + commandText.Append("DELETE FROM public.test_table WHERE int4_field > $1;\r\n"); + commandText.Append("GET DIAGNOSTICS rows = ROW_COUNT;\r\n"); + commandText.Append("IF rows > 0 THEN\r\n"); + commandText.Append("\t\tRETURN TRUE;\r\n"); + commandText.Append("ELSE\r\n"); + commandText.Append("\t\tRETURN FALSE;\r\n"); + commandText.Append("END IF;\r\n"); + commandText.Append("END;\r\n"); + commandText.Append("'\r\n"); + commandText.Append("LANGUAGE 'plpgsql' VOLATILE;"); command.CommandText = commandText.ToString(); Index: PgCommandBuilderTest.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source/PgCommandBuilderTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PgCommandBuilderTest.cs 22 Aug 2003 19:40:36 -0000 1.3 --- PgCommandBuilderTest.cs 25 Oct 2003 20:57:49 -0000 1.4 *************** *** 148,151 **** --- 148,177 ---- [Test] + public void DeriveParameters2() + { + PgTransaction transaction = Connection.BeginTransaction(); + + PgCommandBuilder builder = new PgCommandBuilder(); + + PgCommand command = new PgCommand("DeriveCount", Connection, transaction); + + command.CommandType = CommandType.StoredProcedure; + + PgCommandBuilder.DeriveParameters(command); + + Console.WriteLine("\r\nPgCommandBuilder - DeriveParameters static Method Test"); + + for (int i = 0; i < command.Parameters.Count; i++) + { + Console.WriteLine("Parameter name: {0}\tParameter Source Column:{1}\tDirection:{2}", + command.Parameters[i].ParameterName, + command.Parameters[i].SourceColumn, + command.Parameters[i].Direction); + } + + transaction.Commit(); + } + + [Test] public void TestWithClosedConnection() { |