You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/05/20 23:35:36 UTC

svn commit: r171158 - in /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests: BaseTest.cs StatementTest.cs

Author: gbayon
Date: Fri May 20 14:35:35 2005
New Revision: 171158

URL: http://svn.apache.org/viewcvs?rev=171158&view=rev
Log:
- Added workaround in test to pass TestExecuteQueryForObjectAsHashtableResultClass
and TestQueryForListWithHashtableResultClass with Oracle/PostgreSQL

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs?rev=171158&r1=171157&r2=171158&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/BaseTest.cs Fri May 20 14:35:35 2005
@@ -20,6 +20,8 @@
 
 namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
 {
+	public delegate string KeyConvert(string key);
+
 	/// <summary>
 	/// Summary description for BaseTest.
 	/// </summary>
@@ -33,6 +35,8 @@
 
 		protected static string ScriptDirectory = null;
 
+		protected static KeyConvert ConvertKey = null;
+
 		/// <summary>
 		/// Constructor
 		/// </summary>
@@ -51,10 +55,38 @@
 			ConfigureHandler handler = new ConfigureHandler(Configure);
 			sqlMap = SqlMapper.ConfigureAndWatch("sqlmap" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config", handler);
 
+			if ( sqlMap.DataSource.Provider.Name.IndexOf("PostgreSql")>=0)
+			{
+				BaseTest.ConvertKey = new KeyConvert(Lower);
+			}
+			else if ( sqlMap.DataSource.Provider.Name.IndexOf("oracle")>=0)
+			{
+				BaseTest.ConvertKey = new KeyConvert(Upper);
+			}
+			else 
+			{
+				BaseTest.ConvertKey = new KeyConvert(Normal);
+			}
+
 //			string loadTime = DateTime.Now.Subtract(start).ToString();
 //			Console.WriteLine("Loading configuration time :"+loadTime);
 		}
 
+		protected static string Normal(string key)
+		{
+			return key;
+		}
+
+		protected static string Upper(string key)
+		{
+			return key.ToUpper();
+		}
+
+		protected static string Lower(string key)
+		{
+			return key.ToLower();
+		}
+
 		/// <summary>
 		/// Configure the SqlMap
 		/// </summary>
@@ -128,6 +160,18 @@
 			Assert.AreEqual("Joe", (string) account["FirstName"], "account.FirstName");
 			Assert.AreEqual("Dalton", (string) account["LastName"], "account.LastName");
 			Assert.AreEqual("Joe.Dalton@somewhere.com", (string) account["EmailAddress"], "account.EmailAddress");
+		}
+
+		/// <summary>
+		/// Verify that the input account is equal to the account(id=1).
+		/// </summary>
+		/// <param name="account">An account as hashtable</param>
+		protected void AssertAccount1AsHashtableForResultClass(Hashtable account)
+		{
+			Assert.AreEqual(1, (int) account[BaseTest.ConvertKey("Id")], "account.Id");
+			Assert.AreEqual("Joe", (string) account[BaseTest.ConvertKey("FirstName")], "account.FirstName");
+			Assert.AreEqual("Dalton", (string) account[BaseTest.ConvertKey("LastName")], "account.LastName");
+			Assert.AreEqual("Joe.Dalton@somewhere.com", (string) account[BaseTest.ConvertKey("EmailAddress")], "account.EmailAddress");
 		}
 
 		/// <summary>

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs?rev=171158&r1=171157&r2=171158&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/StatementTest.cs Fri May 20 14:35:35 2005
@@ -144,7 +144,7 @@
 		public void TestExecuteQueryForObjectAsHashtableResultClass()
 		{
 			Hashtable account = (Hashtable) sqlMap.QueryForObject("GetAccountAsHashtableResultClass", 1);
-			AssertAccount1AsHashtable(account);
+			AssertAccount1AsHashtableForResultClass(account);
 		}
 
 		/// <summary>
@@ -280,14 +280,14 @@
 		{
 			IList list = sqlMap.QueryForList("GetAllAccountsAsHashtableViaResultClass", null);
 
-			AssertAccount1AsHashtable((Hashtable) list[0]);
+			AssertAccount1AsHashtableForResultClass((Hashtable) list[0]);
 			Assert.AreEqual(5, list.Count);
 
-			Assert.AreEqual(1, ((Hashtable) list[0])["Id"]);
-			Assert.AreEqual(2, ((Hashtable) list[1])["Id"]);
-			Assert.AreEqual(3, ((Hashtable) list[2])["Id"]);
-			Assert.AreEqual(4, ((Hashtable) list[3])["Id"]);
-			Assert.AreEqual(5, ((Hashtable) list[4])["Id"]);
+			Assert.AreEqual(1, ((Hashtable) list[0])[BaseTest.ConvertKey("Id")]);
+			Assert.AreEqual(2, ((Hashtable) list[1])[BaseTest.ConvertKey("Id")]);
+			Assert.AreEqual(3, ((Hashtable) list[2])[BaseTest.ConvertKey("Id")]);
+			Assert.AreEqual(4, ((Hashtable) list[3])[BaseTest.ConvertKey("Id")]);
+			Assert.AreEqual(5, ((Hashtable) list[4])[BaseTest.ConvertKey("Id")]);
 		}
 
 		/// <summary>