Skip to content

Commit 56843c7

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
Add basic async OneToOneType persistence test.
1 parent 115dbc6 commit 56843c7

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 NHibernate.Test.NHSpecificTest;
12+
using NUnit.Framework;
13+
14+
namespace NHibernate.Test.OneToOneType
15+
{
16+
using System.Threading.Tasks;
17+
[TestFixture]
18+
public class FixtureAsync : BugTestCase
19+
{
20+
protected override void OnTearDown()
21+
{
22+
using (var s = Sfi.OpenSession())
23+
using (var tx = s.BeginTransaction())
24+
{
25+
s.CreateQuery("delete from Details").ExecuteUpdate();
26+
s.CreateQuery("delete from Owner").ExecuteUpdate();
27+
28+
tx.Commit();
29+
}
30+
}
31+
32+
[Test]
33+
public async Task OneToOnePersistedOnOwnerUpdateAsync()
34+
{
35+
object ownerId;
36+
37+
using (var s = Sfi.OpenSession())
38+
using (var tx = s.BeginTransaction())
39+
{
40+
var owner = new Owner()
41+
{
42+
Name = "Owner",
43+
};
44+
45+
ownerId = await (s.SaveAsync(owner));
46+
47+
await (tx.CommitAsync());
48+
}
49+
50+
using (var s = Sfi.OpenSession())
51+
using (var tx = s.BeginTransaction())
52+
{
53+
Owner owner = await (s.LoadAsync<Owner>(ownerId));
54+
55+
owner.Details = new Details()
56+
{
57+
Data = "Owner Details"
58+
};
59+
60+
await (tx.CommitAsync());
61+
}
62+
63+
using (var s = Sfi.OpenSession())
64+
using (var tx = s.BeginTransaction())
65+
{
66+
Owner owner = await (s.GetAsync<Owner>(ownerId));
67+
68+
Assert.NotNull(owner.Details);
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)