Skip to content

Commit ef1c05c

Browse files
committed
NH-2378 - Fix fixture tear down
1 parent ec8847f commit ef1c05c

File tree

1 file changed

+22
-26
lines changed
  • src/NHibernate.Test/NHSpecificTest/NH2378

1 file changed

+22
-26
lines changed

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

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ public class Fixture : BugTestCase
99
{
1010
protected override void OnSetUp()
1111
{
12-
base.OnSetUp();
13-
using (var session = this.OpenSession())
12+
using (var session = OpenSession())
1413
using (var tx = session.BeginTransaction())
1514
{
1615
var entity = new TestEntity();
@@ -31,40 +30,37 @@ protected override void OnSetUp()
3130

3231
protected override void OnTearDown()
3332
{
34-
base.OnTearDown();
35-
using (ISession session = this.OpenSession())
33+
using (var session = OpenSession())
34+
using (var tx = session.BeginTransaction())
3635
{
37-
string hql = "from System.Object";
38-
session.Delete(hql);
39-
session.Flush();
36+
session.Delete("from System.Object");
37+
tx.Commit();
4038
}
4139
}
42-
4340

4441
[Test]
4542
public void ShortEntityCanBeQueryCorrectlyUsingLinqProvider()
4643
{
47-
using (ISession session = this.OpenSession())
44+
using (var session = OpenSession())
45+
using (session.BeginTransaction())
4846
{
49-
IQueryable<TestEntity> query = session.Query<TestEntity>();
50-
IQueryable<TestEntityDto> list = query.Select(o => new TestEntityDto
51-
{
52-
EntityId = o.Id,
53-
EntityName = o.Name,
54-
PersonId =
55-
(o.TestPerson != null)
56-
? o.TestPerson.Id
57-
: (short) 0,
58-
PersonName =
59-
(o.TestPerson != null)
60-
? o.TestPerson.Name
61-
: string.Empty
62-
});
47+
var m = session.Query<TestEntity>()
48+
.Select(o => new TestEntityDto
49+
{
50+
EntityId = o.Id,
51+
EntityName = o.Name,
52+
PersonId = (o.TestPerson != null)
53+
? o.TestPerson.Id
54+
: (short) 0,
55+
PersonName = (o.TestPerson != null)
56+
? o.TestPerson.Name
57+
: string.Empty
58+
})
59+
.Where(o => o.PersonId == 2)
60+
.ToList();
6361

64-
IQueryable<TestEntityDto> m = list.Where(o => o.PersonId == 2);
6562

66-
67-
Assert.AreEqual(1, m.Count());
63+
Assert.That(m.Count, Is.EqualTo(1));
6864
}
6965
}
7066
}

0 commit comments

Comments
 (0)