|
| 1 | +using NHibernate.Dialect; |
1 | 2 | using NUnit.Framework; |
2 | 3 |
|
3 | 4 | namespace NHibernate.Test.NHSpecificTest.NH1675 |
4 | 5 | { |
5 | 6 | [TestFixture] |
6 | 7 | public class Fixture : BugTestCase |
7 | 8 | { |
8 | | - [Test] |
9 | | - public void ShouldWorkUsingDistinctAndLimits() |
| 9 | + protected override bool AppliesTo(Dialect.Dialect dialect) |
| 10 | + { |
| 11 | + return dialect.GetType() == typeof(MsSql2005Dialect) || dialect.GetType() == typeof(MsSql2008Dialect); |
| 12 | + } |
| 13 | + |
| 14 | + protected override void OnSetUp() |
10 | 15 | { |
11 | | - using (ISession s = OpenSession()) |
12 | | - using (ITransaction tx = s.BeginTransaction()) |
| 16 | + using (var s = OpenSession()) |
| 17 | + using (var tx = s.BeginTransaction()) |
13 | 18 | { |
14 | | - for (int i = 0; i < 5; i++) |
| 19 | + for (var i = 0; i < 5; i++) |
15 | 20 | { |
16 | 21 | s.Save(new Person {FirstName = "Name" + i}); |
17 | 22 | } |
18 | 23 | tx.Commit(); |
19 | 24 | } |
| 25 | + } |
20 | 26 |
|
21 | | - using (ISession s = OpenSession()) |
| 27 | + [Test] |
| 28 | + public void ShouldWorkUsingDistinctAndLimits() |
| 29 | + { |
| 30 | + using (var s = OpenSession()) |
22 | 31 | { |
23 | | - var q =s.CreateQuery("select distinct p from Person p").SetFirstResult(0).SetMaxResults(10); |
24 | | - Assert.That(q.List().Count, Is.EqualTo(5)); |
| 32 | + var q = s.CreateQuery("select distinct p from Person p").SetFirstResult(0).SetMaxResults(10); |
| 33 | + Assert.That(q.List(), Has.Count.EqualTo(5)); |
25 | 34 | } |
| 35 | + } |
26 | 36 |
|
27 | | - // clean up |
28 | | - using (ISession s = OpenSession()) |
29 | | - using (ITransaction tx = s.BeginTransaction()) |
| 37 | + protected override void OnTearDown() |
| 38 | + { |
| 39 | + using (var s = OpenSession()) |
| 40 | + using (var tx = s.BeginTransaction()) |
30 | 41 | { |
31 | 42 | s.Delete("from Person"); |
32 | 43 | tx.Commit(); |
|
0 commit comments