Skip to content

Commit 05779ac

Browse files
committed
Clean up testcase for GH1228
1 parent d638d3d commit 05779ac

File tree

1 file changed

+38
-72
lines changed
  • src/NHibernate.Test/NHSpecificTest/GH1228

1 file changed

+38
-72
lines changed

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

Lines changed: 38 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,126 +7,92 @@ public class Fixture : BugTestCase
77
[Test]
88
public void TestOk()
99
{
10-
using (ISession s = OpenSession())
10+
using var s = OpenSession();
1111
{
12-
using (ITransaction t = s.BeginTransaction())
13-
{
14-
try
15-
{
16-
{
17-
var queryThatWorks = s.CreateQuery(@"
12+
var queryThatWorks = s.CreateQuery(
13+
@"
1814
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS ROOT
1915
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS inv
2016
, ROOT.Folder AS ROOT_Folder
2117
WHERE ROOT_Folder.Shelf = inv AND inv.Id = 1
2218
) )
2319
AND ROOT.Name = 'SomeName'");
24-
queryThatWorks.List();
25-
}
26-
{
27-
var queryThatWorks = s.CreateQuery(@"
20+
queryThatWorks.List();
21+
}
22+
{
23+
var queryThatWorks = s.CreateQuery(
24+
@"
2825
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS ROOT
2926
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS sheet
3027
, ROOT.Folders AS ROOT_Folder
3128
WHERE ROOT_Folder = sheet.Folder AND sheet.Name = 'SomeName'
3229
) )
3330
AND ROOT.Id = 1");
34-
queryThatWorks.List();
35-
}
36-
}
37-
finally
38-
{
39-
s.Delete("from Sheet");
40-
s.Delete("from Folder");
41-
s.Delete("from Shelf");
42-
t.Commit();
43-
}
44-
}
31+
queryThatWorks.List();
4532
}
4633
}
4734

4835
[Test]
4936
public void TestWrongSql()
5037
{
51-
using (ISession s = OpenSession())
38+
using var s = OpenSession();
5239
{
53-
using (ITransaction t = s.BeginTransaction())
54-
{
55-
try
56-
{
57-
{
58-
var queryThatCreatesWrongSQL = s.CreateQuery(@"
40+
var queryThatCreatesWrongSQL = s.CreateQuery(
41+
@"
5942
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS ROOT
6043
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS inv
6144
JOIN ROOT.Folder AS ROOT_Folder
6245
WHERE ROOT_Folder.Shelf = inv AND inv.Id = 1
6346
) )
6447
AND ROOT.Name = 'SomeName'");
65-
queryThatCreatesWrongSQL.List();
66-
}
67-
{
68-
// The only assertion here is that the generated SQL is valid and can be executed.
69-
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
70-
var queryThatCreatesWrongSQL = s.CreateQuery(@"
48+
queryThatCreatesWrongSQL.List();
49+
}
50+
{
51+
// The only assertion here is that the generated SQL is valid and can be executed.
52+
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
53+
var queryThatCreatesWrongSQL = s.CreateQuery(
54+
@"
7155
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS ROOT
7256
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS sheet
7357
JOIN ROOT.Folders AS ROOT_Folder
7458
WHERE ROOT_Folder = sheet.Folder AND sheet.Name = 'SomeName'
7559
) )
7660
AND ROOT.Id = 1");
77-
queryThatCreatesWrongSQL.List();
78-
// The only assertion here is that the generated SQL is valid and can be executed.
79-
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
80-
}
81-
}
82-
finally
83-
{
84-
s.Delete("from Sheet");
85-
s.Delete("from Folder");
86-
s.Delete("from Shelf");
87-
t.Commit();
88-
}
89-
}
61+
queryThatCreatesWrongSQL.List();
62+
// The only assertion here is that the generated SQL is valid and can be executed.
63+
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
9064
}
9165
}
9266

9367
[Test]
94-
public void Test3() {
95-
using (ISession s = OpenSession()) {
96-
using (ITransaction t = s.BeginTransaction()) {
97-
try {
98-
{
99-
// The only assertion here is that the generated SQL is valid and can be executed.
100-
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
101-
var queryThatCreatesWrongSQL = s.CreateQuery(@"
68+
public void Test3()
69+
{
70+
using var s = OpenSession();
71+
{
72+
// The only assertion here is that the generated SQL is valid and can be executed.
73+
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
74+
var queryThatCreatesWrongSQL = s.CreateQuery(
75+
@"
10276
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS ROOT
10377
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS sheet
10478
JOIN sheet.Folder AS folder
10579
WHERE folder.Shelf = ROOT AND sheet.Name = 'SomeName'
10680
) )
10781
AND ROOT.Id = 1");
108-
queryThatCreatesWrongSQL.List();
109-
// The only assertion here is that the generated SQL is valid and can be executed.
110-
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
111-
}
112-
{
113-
var queryThatCreatesWrongSQL = s.CreateQuery(@"
82+
queryThatCreatesWrongSQL.List();
83+
// The only assertion here is that the generated SQL is valid and can be executed.
84+
// Right now, the generated SQL is missing the JOIN inside the subselect (EXISTS) to Folder.
85+
}
86+
{
87+
var queryThatCreatesWrongSQL = s.CreateQuery(
88+
@"
11489
SELECT ROOT FROM NHibernate.Test.NHSpecificTest.GH1228.Sheet AS ROOT
11590
WHERE (EXISTS (FROM NHibernate.Test.NHSpecificTest.GH1228.Shelf AS inv
11691
JOIN inv.Folders AS folder
11792
WHERE folder = ROOT.Folder AND inv.Id = 1
11893
) )
11994
AND ROOT.Name = 'SomeName'");
120-
queryThatCreatesWrongSQL.List();
121-
}
122-
}
123-
finally {
124-
s.Delete("from Sheet");
125-
s.Delete("from Folder");
126-
s.Delete("from Shelf");
127-
t.Commit();
128-
}
129-
}
95+
queryThatCreatesWrongSQL.List();
13096
}
13197
}
13298
}

0 commit comments

Comments
 (0)