Skip to content

Commit 315c79c

Browse files
Enable query cache key hashcode tests
1 parent 5891251 commit 315c79c

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/NHibernate.Test/CacheTest/FilterKeyFixture.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,17 @@ public void HashCode()
112112
[Test]
113113
public void NotEqualHashCode()
114114
{
115-
// This test is debatable, since GetHashCode semantic does not guarantee no collision may ever occur.
115+
// GetHashCode semantic does not guarantee no collision may ever occur, but the algorithm should
116+
// generates different hashcodes for similar but inequal cases. These tests check that cache keys
117+
// for a query generated for different parameters values are no more equal.
116118
FilterDescLikeToCompare(out var fk, out var fk1, false);
117-
// Unfortunately due to https://stackoverflow.com/a/5927853/1178314 and our implementation resulting in a call
118-
// to GetHashCode on a KeyValuePair<string, TypedValue>, following assert always fails.
119-
//Assert.That(fk.GetHashCode(), Is.Not.EqualTo(fk1.GetHashCode()), "fk & fk1");
119+
Assert.That(fk.GetHashCode(), Is.Not.EqualTo(fk1.GetHashCode()), "fk & fk1");
120120

121121
FilterDescValueToCompare(out var fvk, out var fvk1, false);
122-
// Unfortunately due to https://stackoverflow.com/a/5927853/1178314 and our implementation resulting in a call
123-
// to GetHashCode on a KeyValuePair<string, TypedValue>, following assert always fails.
124-
//Assert.That(fvk.GetHashCode(), Is.Not.EqualTo(fvk1.GetHashCode()), "fvk & fvk1");
122+
Assert.That(fvk.GetHashCode(), Is.Not.EqualTo(fvk1.GetHashCode()), "fvk & fvk1");
125123

126124
FilterValueInToCompare(out var fik, out var fik1, false);
127-
// Unfortunately due to https://stackoverflow.com/a/5927853/1178314 and our implementation resulting in a call
128-
// to GetHashCode on a KeyValuePair<string, TypedValue>, following assert always fails.
129-
//Assert.That(fik.GetHashCode(), Is.Not.EqualTo(fik1.GetHashCode()), "fik & fik1");
125+
Assert.That(fik.GetHashCode(), Is.Not.EqualTo(fik1.GetHashCode()), "fik & fik1");
130126

131127
Assert.That(fk.GetHashCode(), Is.Not.EqualTo(fvk.GetHashCode()), "fk & fvk");
132128
Assert.That(fk1.GetHashCode(), Is.Not.EqualTo(fvk1.GetHashCode()), "fk1 & fvk1");

src/NHibernate.Test/CacheTest/QueryKeyFixture.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,14 @@ public void HashCodeWithFilters()
8787
[Test]
8888
public void NotEqualHashCodeWithFilters()
8989
{
90+
// GetHashCode semantic does not guarantee no collision may ever occur, but the algorithm should
91+
// generates different hashcodes for similar but inequal cases. These tests check that cache keys
92+
// for a query generated for different parameters values are no more equal.
9093
QueryKeyFilterDescLikeToCompare(out var qk, out var qk1, false);
91-
// Unfortunately due to https://stackoverflow.com/a/5927853/1178314 and our implementation resulting in a call
92-
// to GetHashCode on a KeyValuePair<string, TypedValue>, following assert always fails.
93-
//Assert.That(qk.GetHashCode(), Is.Not.EqualTo(qk1.GetHashCode()), "qk & qk1");
94+
Assert.That(qk.GetHashCode(), Is.Not.EqualTo(qk1.GetHashCode()), "qk & qk1");
9495

9596
QueryKeyFilterDescValueToCompare(out var qvk, out var qvk1, false);
96-
// Unfortunately due to https://stackoverflow.com/a/5927853/1178314 and our implementation resulting in a call
97-
// to GetHashCode on a KeyValuePair<string, TypedValue>, following assert always fails.
98-
//Assert.That(qvk.GetHashCode(), Is.Not.EqualTo(qvk1.GetHashCode()), "qvk & qvk1");
97+
Assert.That(qvk.GetHashCode(), Is.Not.EqualTo(qvk1.GetHashCode()), "qvk & qvk1");
9998

10099
Assert.That(qk.GetHashCode(), Is.Not.EqualTo(qvk.GetHashCode()), "qk & qvk");
101100
Assert.That(qk1.GetHashCode(), Is.Not.EqualTo(qvk1.GetHashCode()), "qk1 & qvk1");

0 commit comments

Comments
 (0)