Author: gbayon
Date: Thu Oct 13 11:13:49 2005
New Revision: 320845

URL: http://svn.apache.org/viewcvs?rev=320845&view=rev
Log:
- Updated for IBATISNET-119

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheKeyTest.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs?rev=320845&r1=320844&r2=320845&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/ObjectProbe.cs 
Thu Oct 13 11:13:49 2005
@@ -680,7 +680,7 @@
                                        if (IsSimpleType(value.GetType())) 
                                        {
                                                hashcode += value.GetHashCode();
-                                               hashcode += 
value.ToString().GetHashCode();
+                                               hashcode += 
value.ToString().GetHashCode()*37;
                                        } 
                                        else 
                                        {

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheKeyTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheKeyTest.cs?rev=320845&r1=320844&r2=320845&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheKeyTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheKeyTest.cs
 Thu Oct 13 11:13:49 2005
@@ -11,17 +11,27 @@
        [TestFixture]
        public class CacheKeyTest
        {
-               private const long A_LONG = 1L;
-               private const long ANOTHER_LONG_WITH_SAME_HASHCODE = 
-9223372034707292159;
+               [Test]
+               public void 
ShouldNotConsider1LAndNegative9223372034707292159LToBeEqual()
+               {
+                       // old version of ObjectProbe gave TestClass based on 
these longs the same HashCode
+                       DoTestClassEquals(1L, -9223372034707292159L);
+               }
 
                [Test]
-               public void 
ShouldNotBeConsideredEqualWhenParametersHaveTheSameHashCodeButAreNotEqual()
+               public void 
ShouldNotConsider1LAndNegative9223372036524971138LToBeEqual()
+               {
+                       // current version of ObjectProbe gives TestClass based 
on these longs the same HashCode
+                       DoTestClassEquals(1L, -9223372036524971138L);
+               }
+
+               private static void DoTestClassEquals(long firstLong, long 
secondLong)
                {
                        TypeHandlerFactory factory = new TypeHandlerFactory();
 
                        // Two cache keys are equal except for the parameter.
-                       CacheKey key = new CacheKey(factory, "STATEMENT", 
"SQL", new TestClass(A_LONG), new string[] {"AProperty"}, 0, 0, 
CacheKeyType.Object);
-                       CacheKey aDifferentKey = new CacheKey(factory, 
"STATEMENT", "SQL", new TestClass(ANOTHER_LONG_WITH_SAME_HASHCODE), new 
string[] {"AProperty"}, 0, 0, CacheKeyType.Object);
+                       CacheKey key = new CacheKey(factory, "STATEMENT", 
"SQL", new TestClass(firstLong), new string[] {"AProperty"}, 0, 0, 
CacheKeyType.Object);
+                       CacheKey aDifferentKey = new CacheKey(factory, 
"STATEMENT", "SQL", new TestClass(secondLong), new string[] {"AProperty"}, 0, 
0, CacheKeyType.Object);
 
                        Assert.IsFalse(aDifferentKey.Equals(key)); // should 
not be equal.
                }


Reply via email to