Skip to content

Commit 1d3d10e

Browse files
author
Tomas Lukac
committed
additional fix of object equality used in tests
1 parent 39bd7e5 commit 1d3d10e

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

src/NHibernate.Test/Async/NHSpecificTest/GH1879/ExpansionRegressionTests.cs

+1-30
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,7 @@ protected override void OnSetUp()
4040
session.Flush();
4141
transaction.Commit();
4242
}
43-
}
44-
45-
protected override void Configure(Configuration configuration)
46-
{
47-
configuration.LinqToHqlGeneratorsRegistry<TestLinqToHqlGeneratorsRegistry>();
48-
}
49-
50-
private class TestLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
51-
{
52-
public TestLinqToHqlGeneratorsRegistry()
53-
{
54-
this.Merge(new ObjectEquality());
55-
}
56-
}
57-
58-
private class ObjectEquality : IHqlGeneratorForMethod
59-
{
60-
public HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
61-
{
62-
return treeBuilder.Equality(visitor.Visit(targetObject).AsExpression(), visitor.Visit(arguments[0]).AsExpression());
63-
}
64-
65-
public IEnumerable<MethodInfo> SupportedMethods
66-
{
67-
get
68-
{
69-
yield return ReflectHelper.GetMethodDefinition<object>(x => x.Equals(x));
70-
}
71-
}
72-
}
43+
}
7344

7445
[Test]
7546
public async Task MethodShouldNotExpandForNonConditionalOrCoalesceAsync()

src/NHibernate.Test/NHSpecificTest/GH1879/ExpansionRegressionTests.cs

+3-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Linq.Expressions;
55
using System.Reflection;
6-
using NHibernate.Cfg;
76
using NHibernate.Hql.Ast;
87
using NHibernate.Linq.Functions;
98
using NHibernate.Linq.Visitors;
@@ -30,19 +29,6 @@ protected override void OnSetUp()
3029
}
3130
}
3231

33-
protected override void Configure(Configuration configuration)
34-
{
35-
configuration.LinqToHqlGeneratorsRegistry<TestLinqToHqlGeneratorsRegistry>();
36-
}
37-
38-
private class TestLinqToHqlGeneratorsRegistry : DefaultLinqToHqlGeneratorsRegistry
39-
{
40-
public TestLinqToHqlGeneratorsRegistry()
41-
{
42-
this.Merge(new ObjectEquality());
43-
}
44-
}
45-
4632
private class ObjectEquality : IHqlGeneratorForMethod
4733
{
4834
public HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
@@ -64,7 +50,7 @@ public void MethodShouldNotExpandForNonConditionalOrCoalesce()
6450
{
6551
using (var session = OpenSession())
6652
{
67-
Assert.That(session.Query<Invoice>().Count(e => ((object)(e.Amount + e.SpecialAmount)).Equals(110)), Is.EqualTo(2));
53+
Assert.That(session.Query<Invoice>().Count(e => ((object) (e.Amount + e.SpecialAmount)).Equals(110)), Is.EqualTo(2));
6854
}
6955
}
7056

@@ -73,7 +59,7 @@ public void MethodShouldNotExpandForConditionalWithPropertyAccessor()
7359
{
7460
using (var session = OpenSession())
7561
{
76-
Assert.That(session.Query<Invoice>().Count(e => ((object)(e.Paid ? e.Amount : e.SpecialAmount)).Equals(10)), Is.EqualTo(2));
62+
Assert.That(session.Query<Invoice>().Count(e => ((object) (e.Paid ? e.Amount : e.SpecialAmount)).Equals(10)), Is.EqualTo(2));
7763
}
7864
}
7965

@@ -82,7 +68,7 @@ public void MethodShouldNotExpandForCoalesceWithPropertyAccessor()
8268
{
8369
using (var session = OpenSession())
8470
{
85-
Assert.That(session.Query<Invoice>().Count(e => ((object)(e.SpecialAmount ?? e.Amount)).Equals(100)), Is.EqualTo(2));
71+
Assert.That(session.Query<Invoice>().Count(e => ((object) (e.SpecialAmount ?? e.Amount)).Equals(100)), Is.EqualTo(2));
8672
}
8773
}
8874
}

0 commit comments

Comments
 (0)