Skip to content

Commit 69d1442

Browse files
Generate async files
1 parent bc7e5c3 commit 69d1442

File tree

2 files changed

+85
-6
lines changed

2 files changed

+85
-6
lines changed

src/NHibernate.Test/Async/NHSpecificTest/NH750/ManyToManyNotFoundIgnoreFixture.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ protected override void OnTearDown()
6262
}
6363
}
6464

65-
protected override void Configure(Configuration configuration)
66-
{
67-
configuration.SetProperty(Cfg.Environment.UseSecondLevelCache, "false");
68-
base.Configure(configuration);
69-
}
70-
7165
[Test]
7266
public async Task DeviceOfDriveAsync()
7367
{
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 NHibernate.Criterion;
13+
using NHibernate.Linq;
14+
using NHibernate.Transform;
15+
using NUnit.Framework;
16+
17+
namespace NHibernate.Test.NHSpecificTest.NH750
18+
{
19+
using System.Threading.Tasks;
20+
[TestFixture]
21+
public class ManyToManyThrowsForNotFoundFixtureAsync : BugTestCase
22+
{
23+
private int _id;
24+
25+
protected override void OnSetUp()
26+
{
27+
using (var s = Sfi.OpenSession())
28+
using (var t = s.BeginTransaction())
29+
{
30+
Device dv = new Device("Device");
31+
Drive dr = new Drive("Drive");
32+
s.Save(dr);
33+
dv.DrivesNotIgnored.Add(dr);
34+
35+
_id = (int) s.Save(dv);
36+
s.Flush();
37+
38+
s.Clear();
39+
s.Delete(dr);
40+
t.Commit();
41+
}
42+
}
43+
44+
protected override void OnTearDown()
45+
{
46+
using (var s = OpenSession())
47+
using (var t = s.BeginTransaction())
48+
{
49+
s.Delete("from Device");
50+
s.Delete("from Drive");
51+
t.Commit();
52+
}
53+
}
54+
55+
[Test]
56+
public async Task LazyLoadAsync()
57+
{
58+
using var s = OpenSession();
59+
var device = await (s.GetAsync<Device>(_id));
60+
Assert.ThrowsAsync<ObjectNotFoundException>(() => NHibernateUtil.InitializeAsync(device.DrivesNotIgnored));
61+
}
62+
63+
[Test]
64+
public void QueryOverFetchAsync()
65+
{
66+
using var s = OpenSession();
67+
var queryOver = s.QueryOver<Device>()
68+
.Fetch(SelectMode.Fetch, x => x.DrivesNotIgnored)
69+
.Where(Restrictions.IdEq(_id))
70+
.TransformUsing(Transformers.DistinctRootEntity);
71+
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (queryOver.SingleOrDefaultAsync()))));
72+
}
73+
74+
[Test]
75+
public void LinqFetchAsync()
76+
{
77+
using var s = OpenSession();
78+
var query = s.Query<Device>()
79+
80+
.Fetch(x => x.DrivesNotIgnored)
81+
.Where(x => x.Id == _id);
82+
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (query.SingleOrDefaultAsync()))));
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)