[pgsqlclient-checkins] pgsqlclient/PostgreSql.Data.PGSqlClient.UnitTests/source PGBaseTest.cs,1.4,1.
Status: Inactive
Brought to you by:
carlosga_fb
|
From: <car...@us...> - 2003-07-18 22:46:10
|
Update of /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient.UnitTests/source
In directory sc8-pr-cvs1:/tmp/cvs-serv10961
Modified Files:
PGBaseTest.cs PGDataAdapterTest.cs
Log Message:
Improved NUnit test suite
Index: PGBaseTest.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient.UnitTests/source/PGBaseTest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PGBaseTest.cs 15 Jul 2003 19:11:39 -0000 1.4
--- PGBaseTest.cs 18 Jul 2003 22:46:04 -0000 1.5
***************
*** 142,146 ****
commandText.Append("bool_field bool,");
commandText.Append("bigint_field int8,");
! // commandText.Append("decimal_field decimal(8,2),");
commandText.Append("smallint_field int2,");
commandText.Append("array_int int2[],");
--- 142,146 ----
commandText.Append("bool_field bool,");
commandText.Append("bigint_field int8,");
! commandText.Append("decimal_field decimal(8,2),");
commandText.Append("smallint_field int2,");
commandText.Append("array_int int2[],");
Index: PGDataAdapterTest.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient/PostgreSql.Data.PGSqlClient.UnitTests/source/PGDataAdapterTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PGDataAdapterTest.cs 15 Jul 2003 19:11:39 -0000 1.2
--- PGDataAdapterTest.cs 18 Jul 2003 22:46:04 -0000 1.3
***************
*** 172,176 ****
[Test]
! public void UpdateBigIntTest()
{
PGTransaction transaction = Connection.BeginTransaction();
--- 172,176 ----
[Test]
! public void UpdateInt2Test()
{
PGTransaction transaction = Connection.BeginTransaction();
***************
*** 178,182 ****
PGDataAdapter adapter = new PGDataAdapter(command);
! adapter.SelectCommand.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 20;
PGCommandBuilder builder = new PGCommandBuilder(adapter);
--- 178,182 ----
PGDataAdapter adapter = new PGDataAdapter(command);
! adapter.SelectCommand.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 40;
PGCommandBuilder builder = new PGCommandBuilder(adapter);
***************
*** 185,189 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["bigint_field"] = System.Int32.MaxValue;
adapter.Update(ds, "public.test_table");
--- 185,189 ----
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["smallint_field"] = System.Int16.MaxValue;
adapter.Update(ds, "public.test_table");
***************
*** 193,200 ****
command.Dispose();
transaction.Commit();
}
[Test]
! public void UpdateSmallIntTest()
{
PGTransaction transaction = Connection.BeginTransaction();
--- 193,207 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT smallint_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 40;
+
+ short val = (short)command.ExecuteScalar();
+
+ Assertion.AssertEquals("smallint_field has not correct value", System.Int16.MaxValue, val);
}
[Test]
! public void UpdateInt8Test()
{
PGTransaction transaction = Connection.BeginTransaction();
***************
*** 202,206 ****
PGDataAdapter adapter = new PGDataAdapter(command);
! adapter.SelectCommand.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 40;
PGCommandBuilder builder = new PGCommandBuilder(adapter);
--- 209,213 ----
PGDataAdapter adapter = new PGDataAdapter(command);
! adapter.SelectCommand.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 20;
PGCommandBuilder builder = new PGCommandBuilder(adapter);
***************
*** 209,213 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["smallint_field"] = System.Int16.MaxValue;
adapter.Update(ds, "public.test_table");
--- 216,220 ----
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["bigint_field"] = System.Int32.MaxValue;
adapter.Update(ds, "public.test_table");
***************
*** 217,220 ****
--- 224,234 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT bigint_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 20;
+
+ long val = (long)command.ExecuteScalar();
+
+ Assertion.AssertEquals("bigint_field has not correct value", System.Int32.MaxValue, val);
}
***************
*** 233,237 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["double_field"] = System.Decimal.MaxValue;
adapter.Update(ds, "public.test_table");
--- 247,251 ----
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["double_field"] = System.Int32.MaxValue;
adapter.Update(ds, "public.test_table");
***************
*** 241,248 ****
command.Dispose();
transaction.Commit();
}
[Test]
- [Ignore("Not implemented.")]
public void UpdateDecimalTest()
{
--- 255,268 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT double_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 50;
+
+ double val = (double)command.ExecuteScalar();
+
+ Assertion.AssertEquals("double_field has not correct value", System.Int32.MaxValue, val);
}
[Test]
public void UpdateDecimalTest()
{
***************
*** 258,262 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["decimal_field"] = System.Int32.MaxValue;
adapter.Update(ds, "public.test_table");
--- 278,282 ----
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["decimal_field"] = System.Int16.MaxValue;
adapter.Update(ds, "public.test_table");
***************
*** 266,269 ****
--- 286,296 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT decimal_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 60;
+
+ decimal val = (decimal)command.ExecuteScalar();
+
+ Assertion.AssertEquals("decimal_field has not correct value", System.Int16.MaxValue, val);
}
***************
*** 282,286 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["date_field"] = DateTime.Now;
adapter.Update(ds, "public.test_table");
--- 309,315 ----
adapter.Fill(ds, "public.test_table");
! DateTime dt = DateTime.Now;
!
! ds.Tables["public.test_table"].Rows[0]["date_field"] = dt;
adapter.Update(ds, "public.test_table");
***************
*** 288,293 ****
adapter.Dispose();
builder.Dispose();
! command.Dispose();
transaction.Commit();
}
--- 317,331 ----
adapter.Dispose();
builder.Dispose();
! command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT date_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 70;
+
+ DateTime val = (DateTime)command.ExecuteScalar();
+
+ Assertion.AssertEquals("date_field has not correct day", dt.Day, val.Day);
+ Assertion.AssertEquals("date_field has not correct month", dt.Month, val.Month);
+ Assertion.AssertEquals("date_field has not correct year", dt.Year, val.Year);
}
***************
*** 306,310 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["time_field"] = DateTime.Now;
adapter.Update(ds, "public.test_table");
--- 344,350 ----
adapter.Fill(ds, "public.test_table");
! DateTime dt = DateTime.Now;
!
! ds.Tables["public.test_table"].Rows[0]["time_field"] = dt;
adapter.Update(ds, "public.test_table");
***************
*** 314,317 ****
--- 354,366 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT time_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 80;
+
+ DateTime val = (DateTime)command.ExecuteScalar();
+
+ Assertion.AssertEquals("time_field has not correct hour", dt.Hour, val.Hour);
+ Assertion.AssertEquals("time_field has not correct minute", dt.Minute, val.Minute);
+ Assertion.AssertEquals("time_field has not correct second", dt.Second, val.Second);
}
***************
*** 330,334 ****
adapter.Fill(ds, "public.test_table");
! ds.Tables["public.test_table"].Rows[0]["timestamp_field"] = DateTime.Now;
adapter.Update(ds, "public.test_table");
--- 379,385 ----
adapter.Fill(ds, "public.test_table");
! DateTime dt = DateTime.Now;
!
! ds.Tables["public.test_table"].Rows[0]["timestamp_field"] = dt;
adapter.Update(ds, "public.test_table");
***************
*** 338,341 ****
--- 389,404 ----
command.Dispose();
transaction.Commit();
+
+ command = new PGCommand("SELECT timestamp_field FROM public.test_table WHERE int_field = @int_field", Connection);
+ command.Parameters.Add("@int_field", PGDbType.Int4, "int_field").Value = 90;
+
+ DateTime val = (DateTime)command.ExecuteScalar();
+
+ Assertion.AssertEquals("timestamp_field has not correct day", dt.Day, val.Day);
+ Assertion.AssertEquals("timestamp_field has not correct month", dt.Month, val.Month);
+ Assertion.AssertEquals("timestamp_field has not correct year", dt.Year, val.Year);
+ Assertion.AssertEquals("timestamp_field has not correct hour", dt.Hour, val.Hour);
+ Assertion.AssertEquals("timestamp_field has not correct minute", dt.Minute, val.Minute);
+ Assertion.AssertEquals("timestamp_field has not correct second", dt.Second, val.Second);
}
|