forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountFixture.cs
58 lines (51 loc) · 1.75 KB
/
CountFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using NHibernate.Cfg;
using NHibernate.Dialect.Function;
using NHibernate.DomainModel;
using NUnit.Framework;
using Environment=NHibernate.Cfg.Environment;
namespace NHibernate.Test.QueryTest
{
using System.Threading.Tasks;
[TestFixture]
public class CountFixtureAsync
{
[Test]
public async Task DefaultAsync()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
cfg.AddResource("NHibernate.DomainModel.Simple.hbm.xml", typeof(Simple).Assembly);
cfg.SetProperty(Environment.Hbm2ddlAuto, "create-drop");
ISessionFactory sf = cfg.BuildSessionFactory();
using (ISession s = sf.OpenSession())
{
object count = await (s.CreateQuery("select count(*) from Simple").UniqueResultAsync());
Assert.IsTrue(count is Int64);
}
await (sf.CloseAsync());
}
[Test]
public async Task OverriddenAsync()
{
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
cfg.SetProperty(Environment.Hbm2ddlAuto, "create-drop");
cfg.AddResource("NHibernate.DomainModel.Simple.hbm.xml", typeof(Simple).Assembly);
cfg.AddSqlFunction("count", new ClassicCountFunction());
ISessionFactory sf = cfg.BuildSessionFactory();
using (ISession s = sf.OpenSession())
{
object count = await (s.CreateQuery("select count(*) from Simple").UniqueResultAsync());
Assert.IsTrue(count is Int32);
}
await (sf.CloseAsync());
}
}
}