Skip to content

Commit d3b7001

Browse files
Generate async files
1 parent 7695e5c commit d3b7001

File tree

1 file changed

+81
-0
lines changed
  • src/NHibernate.Test/Async/NHSpecificTest/GH3365

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System.Linq;
12+
using NUnit.Framework;
13+
using NHibernate.Linq;
14+
15+
namespace NHibernate.Test.NHSpecificTest.GH3365
16+
{
17+
using System.Threading.Tasks;
18+
[TestFixture]
19+
public class FixtureAsync : BugTestCase
20+
{
21+
protected override void OnSetUp()
22+
{
23+
using (var session = OpenSession())
24+
using (var transaction = session.BeginTransaction())
25+
{
26+
27+
var e1 = new Parent { Type = TestEnum.A | TestEnum.C };
28+
session.Save(e1);
29+
30+
var e2 = new Child { Type = TestEnum.D, Parent = e1 };
31+
session.Save(e2);
32+
33+
var e3 = new Child { Type = TestEnum.C, Parent = e1 };
34+
session.Save(e3);
35+
36+
session.Flush();
37+
transaction.Commit();
38+
}
39+
}
40+
41+
[Test]
42+
public async Task SelectClassAsync()
43+
{
44+
using (var session = OpenSession())
45+
using (session.BeginTransaction())
46+
{
47+
var resultFound = await (session.Query<Parent>().Where(x => x.Type.HasFlag(TestEnum.A)).FirstOrDefaultAsync());
48+
49+
var resultNotFound = await (session.Query<Parent>().Where(x => x.Type.HasFlag(TestEnum.D)).FirstOrDefaultAsync());
50+
51+
Assert.That(resultFound, Is.Not.Null);
52+
Assert.That(resultNotFound, Is.Null);
53+
}
54+
}
55+
56+
[Test]
57+
public async Task SelectChildClassContainedInParentAsync()
58+
{
59+
using (var session = OpenSession())
60+
using (session.BeginTransaction())
61+
{
62+
var result = await (session.Query<Child>().Where(x => x.Parent.Type.HasFlag(x.Type)).FirstOrDefaultAsync());
63+
64+
Assert.That(result, Is.Not.Null);
65+
}
66+
}
67+
68+
protected override void OnTearDown()
69+
{
70+
base.OnTearDown();
71+
using (ISession session = this.OpenSession())
72+
{
73+
foreach (var entity in new[] { nameof(Child), nameof(Parent) })
74+
{
75+
session.Delete($"from {entity}");
76+
session.Flush();
77+
}
78+
}
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)