Author: gbayon
Date: Thu May 25 09:11:28 2006
New Revision: 409410

URL: http://svn.apache.org/viewvc?rev=409410&view=rev
Log:
- Fix from Tom Nguyen + nunit test

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs?rev=409410&r1=409409&r2=409410&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs Thu May 25 
09:11:28 2006
@@ -173,6 +173,7 @@
     public class PropertySon : Property
     {
         private int _int = int.MinValue;
+        private float _float = float.MinValue;
 
         private int PrivateIndex
         {
@@ -205,6 +206,12 @@
         {
             get { return new DateTime(2000,1,1); }
             set { throw new InvalidOperationException("Test virtual"); }
+        }
+
+        public new float Float
+        {
+            get { return _float; }
+            set { _float = value*2; }
         }
     }
 }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs?rev=409410&r1=409409&r2=409410&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
 Thu May 25 09:11:28 2006
@@ -1,8 +1,7 @@
 using System;
-using System.Reflection;
+
 using IBatisNet.Common.Test.Domain;
 using IBatisNet.Common.Utilities;
-using IBatisNet.Common.Utilities.Objects;
 using IBatisNet.Common.Utilities.Objects.Members;
 using NUnit.Framework;
 
@@ -138,8 +137,6 @@
             IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(PropertySon), "Account");
             ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "Account");
 
-            PropertySon prop = new PropertySon();
-
             PropertySon son = new PropertySon();
             Account account = (Account)accessorGet.Get(son);
 
@@ -157,8 +154,6 @@
             IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(PropertySon), "Int");
             ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "Int");
 
-            PropertySon prop = new PropertySon();
-
             PropertySon son = new PropertySon();
             Int32 i = (Int32)accessorGet.Get(son);
 
@@ -176,8 +171,6 @@
             IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(PropertySon), "DateTime");
             ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "DateTime");
 
-            PropertySon prop = new PropertySon();
-
             PropertySon son = new PropertySon();
             DateTime date = (DateTime)accessorGet.Get(son);
 
@@ -193,8 +186,6 @@
         {
             ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "PrivateIndex");
 
-            PropertySon prop = new PropertySon();
-
             PropertySon son = new PropertySon();
             accessorSet.Set(son, -99);
 
@@ -209,14 +200,39 @@
         {
             ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "Index");
 
-            PropertySon prop = new PropertySon();
-
             PropertySon son = new PropertySon();
             accessorSet.Set(son, -99);
 
             Assert.AreEqual(-99, son.Index);
         }
 
+        /// <summary>
+        /// Test set IMemberAccessor on a property override by new
+        /// </summary>
+        [Test]
+        public void TestSetPropertyOverrideByNew()
+        {
+            ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(PropertySon), "Float");
+
+            PropertySon son = new PropertySon();
+            accessorSet.Set(son, -99.99f);
+
+            Assert.AreEqual(-99.99f*2, son.Float);
+        }
+
+        /// <summary>
+        /// Test get IMemberAccessor on a property override by new
+        /// </summary>
+        [Test]
+        public void TestGetPropertyOverrideByNew()
+        {
+            IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(PropertySon), "Float");
+
+            PropertySon son = new PropertySon();
+            son.Float = -99.99f;
+
+            Assert.AreEqual(-99.99f * 2, accessorGet.Get(son));
+        }
     }
 
 }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs?rev=409410&r1=409409&r2=409410&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
 Thu May 25 09:11:28 2006
@@ -51,7 +51,7 @@
         private Type _targetType = null;
 
         /// <summary>
-        /// Initializes a new instance of the <see 
cref="T:DelegatePropertyGetAccessor"/> class
+        /// Initializes a new instance of the <see 
cref="DelegatePropertyGetAccessor"/> class
         /// for get property access via DynamicMethod.
         /// </summary>
         /// <param name="targetObjectType">Type of the target object.</param>

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs?rev=409410&r1=409409&r2=409410&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/DataExchange/DotNetObjectDataExchange.cs
 Thu May 25 09:11:28 2006
@@ -78,8 +78,9 @@
                /// <param name="dataBaseValue"></param>
                public override void SetData(ref object target, ResultProperty 
mapping, object dataBaseValue)
                {
-            if ( (target.GetType() != _parameterClass)
-                && !_parameterClass.IsSubclassOf(target.GetType())) 
+                   Type targetType = target.GetType();
+            if ((targetType != _parameterClass)
+                && !targetType.IsSubclassOf(_parameterClass)) 
                        {
                 throw new ArgumentException("Could not set value of type '" + 
target.GetType() + "' in property '" + mapping.PropertyName + "' of type '" + 
_parameterClass + "'");
                        }


Reply via email to