|
| 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 NUnit.Framework; |
| 12 | + |
| 13 | +namespace NHibernate.Test.NHSpecificTest.NH2714 |
| 14 | +{ |
| 15 | + using System.Threading.Tasks; |
| 16 | + [TestFixture] |
| 17 | + public class FixtureAsync : BugTestCase |
| 18 | + { |
| 19 | + private const int ExtraId = 500; |
| 20 | + |
| 21 | + protected override void OnTearDown() |
| 22 | + { |
| 23 | + using (ISession s = OpenSession()) |
| 24 | + { |
| 25 | + s.Delete($"from {nameof(Item)}"); |
| 26 | + s.Flush(); |
| 27 | + s.Delete($"from {nameof(Information)}"); |
| 28 | + s.Flush(); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + [Test] |
| 33 | + public async Task PropertyRefUsesOtherColumnsAsync() |
| 34 | + { |
| 35 | + var information = new Information {Name = "First", ExtraId = ExtraId}; |
| 36 | + |
| 37 | + var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId}; |
| 38 | + |
| 39 | + using (ISession session = OpenSession()) |
| 40 | + { |
| 41 | + await (session.SaveAsync(information)); |
| 42 | + await (session.SaveAsync(item)); |
| 43 | + await (session.FlushAsync()); |
| 44 | + } |
| 45 | + |
| 46 | + using (ISession session = OpenSession()) |
| 47 | + { |
| 48 | + var otherInformation = await (session.GetAsync<Information>(information.Id)); |
| 49 | + Assert.That(otherInformation.Items.Count, Is.EqualTo(1)); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + [Test] |
| 54 | + public async Task ChildKeyPropertiesOfParentAreRetrievedAsync() |
| 55 | + { |
| 56 | + var information = new Information {Name = "First", ExtraId = ExtraId}; |
| 57 | + |
| 58 | + var item = new Item {Id = 1, Name = information.Name, ExtraId = information.ExtraId}; |
| 59 | + |
| 60 | + using (ISession session = OpenSession()) |
| 61 | + { |
| 62 | + await (session.SaveAsync(information)); |
| 63 | + await (session.SaveAsync(item)); |
| 64 | + await (session.FlushAsync()); |
| 65 | + } |
| 66 | + |
| 67 | + using (ISession session = OpenSession()) |
| 68 | + { |
| 69 | + var otherInformation = await (session.GetAsync<Information>(information.Id)); |
| 70 | + |
| 71 | + Assert.That(otherInformation.Name, Is.EqualTo(information.Name)); |
| 72 | + Assert.That(otherInformation.ExtraId, Is.EqualTo(information.ExtraId)); |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments