|
| 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.Collections.Generic; |
| 12 | +using System.Linq; |
| 13 | +using NHibernate.Linq; |
| 14 | +using NUnit.Framework; |
| 15 | + |
| 16 | +namespace NHibernate.Test.NHSpecificTest.GH3424 |
| 17 | +{ |
| 18 | + using System.Threading.Tasks; |
| 19 | + [TestFixture] |
| 20 | + public class FixtureAsync : BugTestCase |
| 21 | + { |
| 22 | + protected override void OnSetUp() |
| 23 | + { |
| 24 | + using var session = OpenSession(); |
| 25 | + using var transaction = session.BeginTransaction(); |
| 26 | + |
| 27 | + var c1 = new Child { Name = "Rob" }; |
| 28 | + session.Save(c1); |
| 29 | + var e1 = new Entity { Name = "Bob", Children = new HashSet<Child> { c1 } }; |
| 30 | + session.Save(e1); |
| 31 | + |
| 32 | + transaction.Commit(); |
| 33 | + } |
| 34 | + |
| 35 | + protected override void OnTearDown() |
| 36 | + { |
| 37 | + using var session = OpenSession(); |
| 38 | + using var transaction = session.BeginTransaction(); |
| 39 | + session.CreateQuery("delete Child").ExecuteUpdate(); |
| 40 | + session.CreateQuery("delete from System.Object").ExecuteUpdate(); |
| 41 | + |
| 42 | + transaction.Commit(); |
| 43 | + } |
| 44 | + |
| 45 | + [Test] |
| 46 | + public async Task QueryingAfterFutureThenClearAsync() |
| 47 | + { |
| 48 | + using var session = OpenSession(); |
| 49 | + using var transaction = session.BeginTransaction(); |
| 50 | + var futureBob = session.Query<Entity>().Where(e => e.Name == "Bob").ToFutureValue(q => q.FirstOrDefault()); |
| 51 | + var bob = await (futureBob.GetValueAsync()); |
| 52 | + Assert.That(bob, Is.Not.Null); |
| 53 | + session.Clear(); |
| 54 | + |
| 55 | + var allQuery = session.Query<Entity>(); |
| 56 | + Assert.That(() => allQuery.ToListAsync(), Has.Count.EqualTo(1)); |
| 57 | + await (transaction.CommitAsync()); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments