|
1 |
| -using System.Collections.Generic; |
2 |
| -using System.IO; |
3 |
| -using System.Reflection; |
4 |
| -using System.Text; |
5 |
| -using NHibernate.Cfg; |
6 |
| -using NHibernate.Tool.hbm2ddl; |
7 | 1 | using NUnit.Framework;
|
8 | 2 |
|
9 | 3 | namespace NHibernate.Test.NHSpecificTest.NH1981
|
10 | 4 | {
|
11 | 5 | [TestFixture]
|
12 | 6 | public class Fixture : BugTestCase
|
13 | 7 | {
|
| 8 | + protected override void OnSetUp() |
| 9 | + { |
| 10 | + using (var s = OpenSession()) |
| 11 | + using (var tx = s.BeginTransaction()) |
| 12 | + { |
| 13 | + s.Save(new Article { Longitude = 90 }); |
| 14 | + s.Save(new Article { Longitude = 90 }); |
| 15 | + s.Save(new Article { Longitude = 120 }); |
| 16 | + |
| 17 | + tx.Commit(); |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + protected override void OnTearDown() |
| 22 | + { |
| 23 | + using (var s = OpenSession()) |
| 24 | + using (var tx = s.BeginTransaction()) |
| 25 | + { |
| 26 | + s.Delete("from Article"); |
| 27 | + |
| 28 | + tx.Commit(); |
| 29 | + } |
| 30 | + } |
| 31 | + |
14 | 32 | [Test]
|
15 | 33 | public void CanGroupWithParameter()
|
16 | 34 | {
|
17 |
| - using (ISession s = OpenSession()) |
18 |
| - using (ITransaction tx = s.BeginTransaction()) |
| 35 | + using (var s = OpenSession()) |
| 36 | + using (s.BeginTransaction()) |
19 | 37 | {
|
20 |
| - s.Save(new Article() { Longitude = 90 }); |
21 |
| - s.Save(new Article() { Longitude = 90 }); |
22 |
| - s.Save(new Article() { Longitude = 120 }); |
| 38 | + const string queryString = |
| 39 | + @"select (Longitude / :divisor) |
| 40 | + from Article |
| 41 | + group by (Longitude / :divisor) |
| 42 | + order by 1"; |
23 | 43 |
|
24 |
| - IList<double> quotients = |
25 |
| - s.CreateQuery( |
26 |
| - @"select (Longitude / :divisor) |
27 |
| - from Article |
28 |
| - group by (Longitude / :divisor)") |
| 44 | + var quotients = s.CreateQuery(queryString) |
29 | 45 | .SetDouble("divisor", 30)
|
30 | 46 | .List<double>();
|
31 | 47 |
|
|
0 commit comments