Author: gbayon
Date: Mon Oct 15 13:21:48 2007
New Revision: 584895

URL: http://svn.apache.org/viewvc?rev=584895&view=rev
Log:
Add unit test for SQL Server passing XML parameter

Added:
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/ps_SelectByIdList.sql
Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj?rev=584895&r1=584894&r2=584895&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/IBatisNet.DataMapper.Test.2005.csproj
 Mon Oct 15 13:21:48 2007
@@ -78,7 +78,7 @@
       <Name>log4net</Name>
       <HintPath>..\External-Bin\Net\1.1\log4net.dll</HintPath>
     </Reference>
-    <Reference Include="nunit.framework, Version=2.4.3.0, Culture=neutral, 
PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+    <Reference Include="nunit.framework, Version=2.4.1.0, Culture=neutral, 
PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
     <Reference Include="System">
       <Name>System</Name>
     </Reference>
@@ -508,6 +508,7 @@
     <None Include="bin\Debug\test.config" />
     <None Include="DataBase-Template.config" />
     <None Include="IBatisNet.Test.build" />
+    <None Include="Scripts\MSSQL\ps_SelectByIdList.sql" />
     <EmbeddedResource Include="bin\Debug\providers.config" />
     <EmbeddedResource Include="bin\Debug\SqlMap_MSSQL_SqlClient.config" />
     <EmbeddedResource Include="Maps\MSSQL\SqlClient\Account.xml" />

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?rev=584895&r1=584894&r2=584895&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
 Mon Oct 15 13:21:48 2007
@@ -731,8 +731,6 @@
                        )
            </insert>
                                
-               <!-- For procedure, the parameters of the parameterMap must in 
the same order 
-               as for the procedure paramaters-->
                <procedure id="InsertAccountViaStoreProcedure" 
parameterMap="insert-params">
                        ps_InsertAccount
                </procedure>
@@ -756,14 +754,22 @@
     <procedure id="SelectAllAccountViaSP" resultClass="Account">
       ps_SelectAllAccount
     </procedure>
+
+    <procedure id="SelectAccountViaXML" parameterMap="XML-params" 
resultClass="Account">
+      ps_SelectByIdList
+    </procedure>
     
        </statements>
 
        <!-- =============================================
-            OPTIONAL EXPLICIT PARAMETER MAP
+            OPTIONAL EXPLICIT PARAMETER MAP 
     ============================================= -->
-       <parameterMaps>   
-               
+       <parameterMaps>
+
+    <parameterMap id="XML-params" class="string" >
+      <parameter property="AccountIds" /> <!-- we don't need dbType="NText" 
but you can specify it --> 
+    </parameterMap>
+    
                <parameterMap id="swap-params" >
                        <parameter property="email1" column="First_Email" />
                        <parameter property="email2" column="Second_Email" />

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs?rev=584895&r1=584894&r2=584895&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/MSSQL/ProcedureTest.cs
 Mon Oct 15 13:21:48 2007
@@ -29,7 +29,9 @@
             InitScript( sqlMap.DataSource, ScriptDirectory + 
"category-procedureWithReturn.sql", false);
                        InitScript( sqlMap.DataSource, ScriptDirectory + 
"ps_SelectAccount.sql", false );
             InitScript( sqlMap.DataSource, ScriptDirectory + 
"ps_SelectAllAccount.sql", false);                            
-                       InitScript( sqlMap.DataSource, ScriptDirectory + 
"swap-procedure.sql" );        
+                       InitScript( sqlMap.DataSource, ScriptDirectory + 
"swap-procedure.sql" );
+            InitScript(sqlMap.DataSource, ScriptDirectory + 
"ps_SelectByIdList.sql");  
+
                }
 
                /// <summary>
@@ -74,6 +76,18 @@
             Assert.AreEqual ( category.Name, category4.Name );
         }
 #endif
+
+        /// <summary>
+        /// Test XML parameter.
+        /// </summary>
+        [Test]
+        public void TestXMLParameter()
+        {
+            string accountIds = "<Accounts><id>3</id><id>4</id></Accounts>";
+
+            IList accounts = sqlMap.QueryForList("SelectAccountViaXML", 
accountIds);
+            Assert.IsTrue(accounts.Count == 2);
+        }
 
         /// <summary>
         /// Test get an account via a store procedure.

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql?rev=584895&r1=584894&r2=584895&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/account-init.sql 
Mon Oct 15 13:21:48 2007
@@ -47,4 +47,6 @@
 if exists (select * from dbo.sysobjects where id = 
object_id(N'[dbo].[ps_swap_email_address]') and OBJECTPROPERTY(id, 
N'IsProcedure') = 1)
 drop procedure [dbo].[ps_swap_email_address]
 
-
+if exists (select * from dbo.sysobjects where id = 
object_id(N'[dbo].[ps_SelectByIdList]') and 
+OBJECTPROPERTY(id, N'IsProcedure') = 1)
+drop procedure [dbo].[ps_SelectByIdList]

Added: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/ps_SelectByIdList.sql
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/ps_SelectByIdList.sql?rev=584895&view=auto
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/ps_SelectByIdList.sql
 (added)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Scripts/MSSQL/ps_SelectByIdList.sql
 Mon Oct 15 13:21:48 2007
@@ -0,0 +1,19 @@
+
+
+CREATE PROCEDURE ps_SelectByIdList(@AccountIds xml) AS
+
+DECLARE @Ids TABLE (ID int) 
+
+INSERT INTO @Ids (ID) SELECT ParamValues.ID.value('.','int')
+FROM @AccountIds.nodes('/Accounts/id') as ParamValues(ID) 
+
+SELECT 
+       Account_ID as Id,
+       Account_FirstName as FirstName,
+       Account_LastName as LastName,
+       Account_Email as EmailAddress
+FROM 
+    Accounts
+INNER JOIN 
+    @Ids p
+ON    Accounts.Account_ID = p.ID
\ No newline at end of file

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config?rev=584895&r1=584894&r2=584895&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/bin/Debug/IBatisNet.DataMapper.Test.dll.config
 Mon Oct 15 13:21:48 2007
@@ -37,14 +37,14 @@
                                <arg key="level" value="ALL" />
                                <arg key="dateTimeFormat" value="yyyy/MM/dd 
HH:mm:ss:SSS" />
                        </logFactoryAdapter>    --> 
- <!--
       <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, 
IBatisNet.Common.Logging.Log4Net">
         <arg key="configType" value="inline" />
       </logFactoryAdapter> 
--->
+
+ <!--
       
      <logFactoryAdapter type="IBatisNet.Common.Logging.Impl.NoOpLoggerFA, 
IBatisNet.Common" />
-
+-->
       
                </logging>
        </iBATIS>


Reply via email to