|
| 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.Cfg.MappingSchema; |
| 13 | +using NHibernate.Mapping.ByCode; |
| 14 | +using NUnit.Framework; |
| 15 | +using NHibernate.Linq; |
| 16 | + |
| 17 | +namespace NHibernate.Test.NHSpecificTest.GH3164 |
| 18 | +{ |
| 19 | + using System.Threading.Tasks; |
| 20 | + [TestFixture] |
| 21 | + public class ByCodeFixtureAsync : TestCaseMappingByCode |
| 22 | + { |
| 23 | + protected override HbmMapping GetMappings() |
| 24 | + { |
| 25 | + var mapper = new ModelMapper(); |
| 26 | + mapper.AddMapping<ContentItemMapping>(); |
| 27 | + mapper.AddMapping<HeadMapping>(); |
| 28 | + |
| 29 | + return mapper.CompileMappingForAllExplicitlyAddedEntities(); |
| 30 | + } |
| 31 | + |
| 32 | + protected override void OnSetUp() |
| 33 | + { |
| 34 | + using (var session = OpenSession()) |
| 35 | + using (var transaction = session.BeginTransaction()) |
| 36 | + { |
| 37 | + var e1 = new ContentItem { Name = "Test" }; |
| 38 | + session.Save(e1); |
| 39 | + |
| 40 | + transaction.Commit(); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + protected override void OnTearDown() |
| 45 | + { |
| 46 | + using (var session = OpenSession()) |
| 47 | + using (var transaction = session.BeginTransaction()) |
| 48 | + { |
| 49 | + session.CreateQuery("delete from System.Object").ExecuteUpdate(); |
| 50 | + |
| 51 | + transaction.Commit(); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + [Test] |
| 56 | + public async Task FetchComponentAsync() |
| 57 | + { |
| 58 | + using (var session = OpenSession()) |
| 59 | + { |
| 60 | + var result = await (session.Query<ContentItem>().Fetch(i => i.Head).ToListAsync()); |
| 61 | + |
| 62 | + Assert.That(result.Count, Is.EqualTo(1)); |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments