|
| 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.GH2627 |
| 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 | + var e1 = new Entity {Name = "Bob"}; |
| 27 | + session.Save(e1); |
| 28 | + |
| 29 | + transaction.Commit(); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + protected override void OnTearDown() |
| 34 | + { |
| 35 | + using (var session = OpenSession()) |
| 36 | + using (var transaction = session.BeginTransaction()) |
| 37 | + { |
| 38 | + session.CreateQuery("delete from Child").ExecuteUpdate(); |
| 39 | + session.CreateQuery("delete from System.Object").ExecuteUpdate(); |
| 40 | + |
| 41 | + transaction.Commit(); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + [Test] |
| 46 | + public async Task NullRefInMergeAsync() |
| 47 | + { |
| 48 | + Child child; |
| 49 | + using (var session = OpenSession()) |
| 50 | + using (var t = session.BeginTransaction()) |
| 51 | + { |
| 52 | + child = new Child |
| 53 | + { |
| 54 | + Parent = await (session.Query<Entity>().FirstOrDefaultAsync()), |
| 55 | + Name = "John" |
| 56 | + }; |
| 57 | + |
| 58 | + await (t.CommitAsync()); |
| 59 | + } |
| 60 | + |
| 61 | + using (var session = OpenSession()) |
| 62 | + using (var t = session.BeginTransaction()) |
| 63 | + { |
| 64 | + await (session.MergeAsync(child)); |
| 65 | + await (t.CommitAsync()); |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments