Skip to content

Commit 57e2623

Browse files
committed
More test cases and clean up
1 parent e33120c commit 57e2623

File tree

1 file changed

+40
-26
lines changed
  • src/NHibernate.Test/NHSpecificTest/GH3334

1 file changed

+40
-26
lines changed

src/NHibernate.Test/NHSpecificTest/GH3334/Fixture.cs

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,32 @@ public class Fixture : BugTestCase
1010
[OneTimeSetUp]
1111
public void OneTimeSetUp()
1212
{
13-
using (var session = OpenSession())
14-
using (var t = session.BeginTransaction())
13+
using var session = OpenSession();
14+
using var t = session.BeginTransaction();
15+
var parent = new Entity
1516
{
16-
var parent = new Entity
17-
{
18-
Name = "Parent1",
19-
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "GrandChild" } } }
20-
};
21-
session.Save(parent);
22-
parent = new Entity
23-
{
24-
Name = "Parent2",
25-
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "XGrandChild" } } }
26-
};
27-
var other = new OtherEntity { Name = "ABC", Entities = {parent}};
28-
parent.OtherEntity = other;
29-
session.Save(parent);
30-
session.Save(other);
31-
t.Commit();
32-
}
33-
34-
Sfi.Statistics.IsStatisticsEnabled = true;
17+
Name = "Parent1",
18+
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "GrandChild" } } }
19+
};
20+
session.Save(parent);
21+
parent = new Entity
22+
{
23+
Name = "Parent2",
24+
Children = { new ChildEntity { Name = "Child", Child = new GrandChildEntity { Name = "XGrandChild" } } }
25+
};
26+
var other = new OtherEntity { Name = "ABC", Entities = {parent}};
27+
parent.OtherEntity = other;
28+
session.Save(parent);
29+
session.Save(other);
30+
t.Commit();
3531
}
3632

3733
[OneTimeTearDown]
3834
public void OneTimeTearDown()
3935
{
40-
Sfi.Statistics.IsStatisticsEnabled = false;
41-
4236
using var session = OpenSession();
4337
using var transaction = session.BeginTransaction();
44-
38+
4539
session.CreateQuery("delete from ChildEntity").ExecuteUpdate();
4640
session.CreateQuery("delete from GrandChildEntity").ExecuteUpdate();
4741
session.CreateQuery("delete from Entity").ExecuteUpdate();
@@ -153,14 +147,34 @@ grandChild.Name like 'A%'
153147
OR otherEntity.Name like 'A%'
154148
)
155149
)");
150+
yield return new("FROM ROOT.Children FoundViaGrandChildG", @"
151+
SELECT ROOT
152+
FROM Entity AS ROOT
153+
WHERE
154+
EXISTS
155+
(FROM ROOT.Children AS child
156+
LEFT JOIN child.Child AS grandChild
157+
WHERE
158+
grandChild.Name like 'G%'
159+
)");
160+
yield return new("FROM ROOT.OtherEntity FoundViaOtherEntityA", @"
161+
SELECT ROOT
162+
FROM Entity AS ROOT
163+
WHERE
164+
EXISTS
165+
(FROM ROOT.OtherEntity AS otherEntity
166+
LEFT JOIN ChildEntity AS child ON child.Parent = ROOT
167+
LEFT JOIN child.Child AS grandChild
168+
WHERE
169+
grandChild.Name like 'A%'
170+
OR otherEntity.Name like 'A%'
171+
)");
156172
}
157173

158174
[Test, TestCaseSource(nameof(GetNoExceptionOnExecuteQueryTestCases))]
159175
public void NoExceptionOnExecuteQuery(TestCaseItem testCase)
160176
{
161177
using var session = OpenSession();
162-
using var _ = session.BeginTransaction();
163-
164178
var q = session.CreateQuery(testCase.Hql);
165179
Assert.That(q.List(), Has.Count.EqualTo(1));
166180
}

0 commit comments

Comments
 (0)