|
| 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; |
| 12 | +using NUnit.Framework; |
| 13 | + |
| 14 | +namespace NHibernate.Test.NHSpecificTest.GH1645 |
| 15 | +{ |
| 16 | + using System.Threading.Tasks; |
| 17 | + [TestFixture] |
| 18 | + public class FixtureAsync : BugTestCase |
| 19 | + { |
| 20 | + private Guid _superParentId; |
| 21 | + private Guid _parentId; |
| 22 | + |
| 23 | + protected override void OnSetUp() |
| 24 | + { |
| 25 | + using (var session = OpenSession()) |
| 26 | + using (var transaction = session.BeginTransaction()) |
| 27 | + { |
| 28 | + var p = new Parent(); |
| 29 | + session.Save(p); |
| 30 | + _parentId = p.Id; |
| 31 | + |
| 32 | + _superParentId = (Guid) session.Save(new SuperParent { Parent = p }); |
| 33 | + |
| 34 | + transaction.Commit(); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + protected override void OnTearDown() |
| 39 | + { |
| 40 | + using (var session = OpenSession()) |
| 41 | + using (var transaction = session.BeginTransaction()) |
| 42 | + { |
| 43 | + // The HQL delete does all the job inside the database without loading the entities, but it does |
| 44 | + // not handle delete order for avoiding violating constraints if any. Use |
| 45 | + // session.Delete("from System.Object"); |
| 46 | + // instead if in need of having NHbernate ordering the deletes, but this will cause |
| 47 | + // loading the entities in the session. |
| 48 | + session.CreateQuery("delete from System.Object").ExecuteUpdate(); |
| 49 | + |
| 50 | + transaction.Commit(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + [Test] |
| 55 | + public async Task SOEOnLoadAsync() |
| 56 | + { |
| 57 | + using (var session = OpenSession()) |
| 58 | + using (session.BeginTransaction()) |
| 59 | + { |
| 60 | + var superParent = await (session.LoadAsync<SuperParent>(_superParentId)); |
| 61 | + Assert.That(() => NHibernateUtil.InitializeAsync(superParent), Throws.Nothing); |
| 62 | + Assert.That(() => NHibernateUtil.InitializeAsync(superParent.Parent), Throws.Nothing); |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments