1- using System ;
2- using NUnit . Framework ;
1+ using NUnit . Framework ;
32
43namespace NHibernate . Test . NHSpecificTest . GH3327
54{
@@ -8,56 +7,46 @@ public class Fixture : BugTestCase
87 {
98 protected override void OnSetUp ( )
109 {
11- Sfi . Statistics . IsStatisticsEnabled = true ;
10+ using var session = OpenSession ( ) ;
11+ using var t = session . BeginTransaction ( ) ;
12+ var parent = new Entity { Name = "Parent" } ;
13+ var child = new ChildEntity { Name = "Child" , Parent = parent } ;
14+ session . Save ( parent ) ;
15+ session . Save ( child ) ;
16+ t . Commit ( ) ;
1217 }
1318
1419 protected override void OnTearDown ( )
1520 {
16- Sfi . Statistics . IsStatisticsEnabled = false ;
17- using ( var session = OpenSession ( ) )
18- using ( var transaction = session . BeginTransaction ( ) )
19- {
20- session . CreateQuery ( "delete from ChildEntity" ) . ExecuteUpdate ( ) ;
21- session . CreateQuery ( "delete from Entity" ) . ExecuteUpdate ( ) ;
21+ using var session = OpenSession ( ) ;
22+ using var transaction = session . BeginTransaction ( ) ;
23+ session . CreateQuery ( "delete from ChildEntity" ) . ExecuteUpdate ( ) ;
24+ session . CreateQuery ( "delete from Entity" ) . ExecuteUpdate ( ) ;
2225
23- transaction . Commit ( ) ;
24- }
26+ transaction . Commit ( ) ;
2527 }
2628
2729 [ Test ]
2830 public void NotIsCorrectlyHandled ( )
2931 {
30- using ( var session = OpenSession ( ) )
31- using ( var t = session . BeginTransaction ( ) )
32- {
33- var parent = new Entity { Name = "Parent" } ;
34- var child = new ChildEntity { Name = "Child" , Parent = parent } ;
35- session . Save ( parent ) ;
36- session . Save ( child ) ;
37- t . Commit ( ) ;
38- }
39-
40- using ( var session = OpenSession ( ) )
41- using ( var _ = session . BeginTransaction ( ) )
42- {
43- var q = session . CreateQuery (
44- @"SELECT COUNT(ROOT.Id)
32+ using var session = OpenSession ( ) ;
33+ var q = session . CreateQuery (
34+ @"SELECT COUNT(ROOT.Id)
4535 FROM Entity AS ROOT
4636 WHERE (
4737 EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT)
4838 AND ROOT.Name = 'Parent'
4939 )" ) ;
50- Assert . That ( q . List ( ) [ 0 ] , Is . EqualTo ( 1 ) ) ;
40+ Assert . That ( q . List ( ) [ 0 ] , Is . EqualTo ( 1 ) ) ;
5141
52- q = session . CreateQuery (
53- @"SELECT COUNT(ROOT.Id)
42+ q = session . CreateQuery (
43+ @"SELECT COUNT(ROOT.Id)
5444 FROM Entity AS ROOT
5545 WHERE NOT (
5646 EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT)
5747 AND ROOT.Name = 'Parent'
5848 )" ) ;
59- Assert . That ( q . List ( ) [ 0 ] , Is . EqualTo ( 0 ) ) ;
60- }
49+ Assert . That ( q . List ( ) [ 0 ] , Is . EqualTo ( 0 ) ) ;
6150 }
6251 }
6352}
0 commit comments