From: <car...@us...> - 2006-03-22 11:01:25
|
Revision: 41 Author: carlosga_fb Date: 2006-03-22 03:01:06 -0800 (Wed, 22 Mar 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=41&view=rev Log Message: ----------- More change on the Unit Test suite Modified Paths: -------------- trunk/pgsqlclient/source/UnitTests/PgArrayTest.cs trunk/pgsqlclient/source/UnitTests/PgBaseTest.cs trunk/pgsqlclient/source/UnitTests/PgCommandBuilderTest.cs trunk/pgsqlclient/source/UnitTests/PgCommandTest.cs trunk/pgsqlclient/source/UnitTests/PgConnectionTest.cs trunk/pgsqlclient/source/UnitTests/PgDataAdapterTest.cs trunk/pgsqlclient/source/UnitTests/PgDataReaderTest.cs trunk/pgsqlclient/source/UnitTests/PgDatabaseSchemaTest.cs trunk/pgsqlclient/source/UnitTests/PgGeometicTypesTest.cs trunk/pgsqlclient/source/UnitTests/PgTransactionTest.cs Modified: trunk/pgsqlclient/source/UnitTests/PgArrayTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgArrayTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgArrayTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -27,10 +27,16 @@ { [TestFixture] public class PgArrayTest : PgBaseTest - { - private int testArrayLength = 100; + { + #region \xB7 Fields \xB7 - [Test] + private int testArrayLength = 100; + + #endregion + + #region \xB7 Unit Tests \xB7 + + [Test] public void Int2ArrayTest() { int id_value = System.DateTime.Now.Millisecond; @@ -79,6 +85,8 @@ Console.WriteLine("Finishing test"); reader.Close(); - } - } + } + + #endregion + } } Modified: trunk/pgsqlclient/source/UnitTests/PgBaseTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgBaseTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgBaseTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -26,119 +26,117 @@ namespace PostgreSql.Data.PostgreSqlClient.UnitTests { - public class PgBaseTest - { - private PgConnection connection; + public abstract class PgBaseTest + { + #region \xB7 Fields \xB7 - public PgConnection Connection + private PgConnection connection; + + #endregion + + #region \xB7 Properties \xB7 + + public PgConnection Connection { get { return connection; } - } + } - public PgBaseTest() + #endregion + + #region \xB7 Constructors \xB7 + + public PgBaseTest() { - } + } - [SetUp] + #endregion + + #region \xB7 SetUp and TearDown \xB7 + + [SetUp] public void SetUp() { try { - dropDatabase(); + DropDatabase(); } - catch{} + catch + { + } - createDatabase(); + CreateDatabase(); // Build the connection string - StringBuilder connString = new StringBuilder(); - connString.AppendFormat( - "User={0};Password={1};Database={2};DataSource={3};Port={4};SSL={5}", - ConfigurationSettings.AppSettings["User"], - ConfigurationSettings.AppSettings["Password"], - ConfigurationSettings.AppSettings["Database"], - ConfigurationSettings.AppSettings["DataSource"], - ConfigurationSettings.AppSettings["Port"], - ConfigurationSettings.AppSettings["SSL"]); + PgConnectionStringBuilder csb = new PgConnectionStringBuilder(); + + csb.DataSource = ConfigurationSettings.AppSettings["DataSource"]; + csb.Database = ConfigurationSettings.AppSettings["Database"]; + csb.UserID = ConfigurationSettings.AppSettings["User"]; + csb.Password = ConfigurationSettings.AppSettings["Password"]; + csb.Port = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]); + csb.Ssl = Convert.ToBoolean(ConfigurationSettings.AppSettings["SSL"]); - connection = new PgConnection(connString.ToString()); - connection.StateChange += new StateChangeEventHandler(stateChange); + connection = new PgConnection(csb.ToString()); + connection.StateChange += new StateChangeEventHandler(StateChange); connection.Open(); - createTables(); - createFunctions(); + CreateTables(); + CreateFunctions(); } [TearDown] public void TearDown() { connection.Close(); - } + } - private void stateChange(object sender, StateChangeEventArgs e) - { - Console.WriteLine("Connection state changed from {0} to {1}", - e.OriginalState, e.CurrentState); - } + #endregion - private void createDatabase() + #region \xB7 Private Methods \xB7 + + private void CreateDatabase() { - StringBuilder connString = new StringBuilder(); - connString.AppendFormat( - "User={0};Password={1};Database={2};DataSource={3};Port={4};SSL={5}", - ConfigurationSettings.AppSettings["User"], - ConfigurationSettings.AppSettings["Password"], - String.Empty, - ConfigurationSettings.AppSettings["DataSource"], - ConfigurationSettings.AppSettings["Port"], - ConfigurationSettings.AppSettings["SSL"]); + PgConnectionStringBuilder csb = new PgConnectionStringBuilder(); - PgConnection connection = new PgConnection(connString.ToString()); + csb.DataSource = ConfigurationSettings.AppSettings["DataSource"]; + csb.Database = ""; + csb.UserID = ConfigurationSettings.AppSettings["User"]; + csb.Password = ConfigurationSettings.AppSettings["Password"]; + csb.Port = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]); + csb.Ssl = Convert.ToBoolean(ConfigurationSettings.AppSettings["SSL"]); + + PgConnection connection = new PgConnection(csb.ToString()); connection.Open(); -#warning "Create dtabase here" - /* - connection.CreateDatabase( - ConfigurationSettings.AppSettings["Database"], - null, - null, - null, - "UNICODE"); - */ - + PgCommand createDatabase = new PgCommand(String.Format("CREATE DATABASE {0} WITH ENCODING='UTF8'", ConfigurationSettings.AppSettings["Database"]), connection); + createDatabase.ExecuteNonQuery(); + createDatabase.Dispose(); + connection.Close(); } - private void dropDatabase() + private void DropDatabase() { - StringBuilder connString = new StringBuilder(); - connString.AppendFormat( - "User={0};Password={1};Database={2};DataSource={3};Port={4};SSL={5}", - ConfigurationSettings.AppSettings["User"], - ConfigurationSettings.AppSettings["Password"], - String.Empty, - ConfigurationSettings.AppSettings["DataSource"], - ConfigurationSettings.AppSettings["Port"], - ConfigurationSettings.AppSettings["SSL"]); + PgConnectionStringBuilder csb = new PgConnectionStringBuilder(); - PgConnection connection = new PgConnection(connString.ToString()); + csb.DataSource = ConfigurationSettings.AppSettings["DataSource"]; + csb.Database = ""; + csb.UserID = ConfigurationSettings.AppSettings["User"]; + csb.Password = ConfigurationSettings.AppSettings["Password"]; + csb.Port = Convert.ToInt32(ConfigurationSettings.AppSettings["Port"]); + csb.Ssl = Convert.ToBoolean(ConfigurationSettings.AppSettings["SSL"]); + + PgConnection connection = new PgConnection(csb.ToString()); connection.Open(); - StringBuilder commandText = new StringBuilder(); - - commandText.AppendFormat( - "drop database {0}", - ConfigurationSettings.AppSettings["Database"]); - - PgCommand command = new PgCommand(commandText.ToString(), connection); - - command.ExecuteNonQuery(); - command.Dispose(); + PgCommand dropDatabase = new PgCommand(String.Format("drop database {0}", ConfigurationSettings.AppSettings["Database"]), connection); + dropDatabase.ExecuteNonQuery(); + dropDatabase.Dispose(); connection.Close(); } - private void createTables() + private void CreateTables() { StringBuilder commandText = new StringBuilder(); @@ -199,11 +197,11 @@ command.ExecuteNonQuery(); command.Dispose(); - insertTestData(); - insertGeometricTestData(); + InsertTestData(); + InsertGeometricTestData(); } - private void createFunctions() + private void CreateFunctions() { // Create language functions StringBuilder commandText = new StringBuilder(); @@ -281,7 +279,7 @@ command.Dispose(); } - private void insertTestData() + private void InsertTestData() { string commandText = "insert into public.test_table values(@int4_field, @char_field, @varchar_field, @single_field, @double_field, @date_Field, @time_field, @timestamp_field, @blob_field, @bool_field)"; @@ -332,7 +330,7 @@ } } - private void insertGeometricTestData() + private void InsertGeometricTestData() { string commandText = "insert into public.geometric_table values(@pk, @point, @box, @circle, @lseg, @path, @polygon)"; @@ -375,6 +373,18 @@ { command.Dispose(); } - } - } + } + + #endregion + + #region \xB7 Event Handlers \xB7 + + private void StateChange(object sender, StateChangeEventArgs e) + { + Console.WriteLine("Connection state changed from {0} to {1}", + e.OriginalState, e.CurrentState); + } + + #endregion + } } \ No newline at end of file Modified: trunk/pgsqlclient/source/UnitTests/PgCommandBuilderTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgCommandBuilderTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgCommandBuilderTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgCommandBuilderTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void GetInsertCommandTest() { PgCommand command = new PgCommand("select * from public.test_table where int4_field = @int4_field and varchar_field = @varchar_field", Connection); @@ -202,6 +204,8 @@ builder.Dispose(); adapter.Dispose(); command.Dispose(); - } - } + } + + #endregion + } } Modified: trunk/pgsqlclient/source/UnitTests/PgCommandTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgCommandTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgCommandTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgCommandTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void ExecuteNonQueryTest() { Console.WriteLine("\r\nPgCommandTest.ExecuteNonQueryTest"); @@ -198,6 +200,7 @@ { Console.Write("{0}\t\t", reader.GetName(i)); } + Console.Write("\r\n"); while (reader.Read()) @@ -214,6 +217,8 @@ command.Dispose(); reader.Close(); - } - } + } + + #endregion + } } Modified: trunk/pgsqlclient/source/UnitTests/PgConnectionTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgConnectionTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgConnectionTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgConnectionTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void BeginTransactionTest() { PgTransaction transaction = Connection.BeginTransaction(); @@ -81,6 +83,8 @@ public void CreateCommandTest() { PgCommand command = Connection.CreateCommand(); - } - } + } + + #endregion + } } \ No newline at end of file Modified: trunk/pgsqlclient/source/UnitTests/PgDataAdapterTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgDataAdapterTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgDataAdapterTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgDataAdapterTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void FillTest() { PgCommand command = new PgCommand("SELECT * FROM public.test_table WHERE date_field = @date_field", Connection); @@ -458,6 +460,8 @@ builder.Dispose(); command.Dispose(); transaction.Commit(); - } - } + } + + #endregion + } } \ No newline at end of file Modified: trunk/pgsqlclient/source/UnitTests/PgDataReaderTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgDataReaderTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgDataReaderTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgDataReaderTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void ReadTest() { PgTransaction transaction = Connection.BeginTransaction(); @@ -241,6 +243,8 @@ reader.Close(); command.Dispose(); - } - } + } + + #endregion + } } \ No newline at end of file Modified: trunk/pgsqlclient/source/UnitTests/PgDatabaseSchemaTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgDatabaseSchemaTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgDatabaseSchemaTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgDatabaseSchemaTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void Aggregates() { DataTable aggregates = Connection.GetSchema("Aggregates", null); @@ -205,6 +207,8 @@ public void Views() { DataTable views = Connection.GetSchema("Views", null); - } - } + } + + #endregion + } } Modified: trunk/pgsqlclient/source/UnitTests/PgGeometicTypesTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgGeometicTypesTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgGeometicTypesTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -27,8 +27,10 @@ { [TestFixture] public class PgGeometricTypesTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void PointTest() { PgCommand command = new PgCommand("select point_field from public.geometric_table where pk = @pk", Connection); @@ -219,6 +221,8 @@ [Ignore("Test not implemented.")] public void CircleArrayTest() { - } - } + } + + #endregion + } } Modified: trunk/pgsqlclient/source/UnitTests/PgTransactionTest.cs =================================================================== --- trunk/pgsqlclient/source/UnitTests/PgTransactionTest.cs 2006-03-22 10:47:41 UTC (rev 40) +++ trunk/pgsqlclient/source/UnitTests/PgTransactionTest.cs 2006-03-22 11:01:06 UTC (rev 41) @@ -25,8 +25,10 @@ { [TestFixture] public class PgTransactionTest : PgBaseTest - { - [Test] + { + #region \xB7 Unit Tests \xB7 + + [Test] public void BeginTransactionTest() { Console.WriteLine("\r\nStarting transaction"); @@ -66,6 +68,8 @@ PgTransaction transaction = Connection.BeginTransaction(); transaction.Rollback(); transaction.Dispose(); - } - } + } + + #endregion + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |