forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
005aa44
commit 5135f15
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/NHibernate.Test/Async/NHSpecificTest/GH3424/Fixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NHibernate.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3424 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
protected override void OnSetUp() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
var c1 = new Child { Name = "Rob" }; | ||
session.Save(c1); | ||
var e1 = new Entity { Name = "Bob", Children = new HashSet<Child> { c1 } }; | ||
session.Save(e1); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
session.CreateQuery("delete Child").ExecuteUpdate(); | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
[Test] | ||
public async Task QueryingAfterFutureThenClearAsync() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
var futureBob = session.Query<Entity>().Where(e => e.Name == "Bob").ToFutureValue(q => q.FirstOrDefault()); | ||
var bob = await (futureBob.GetValueAsync()); | ||
Assert.That(bob, Is.Not.Null); | ||
session.Clear(); | ||
|
||
var allQuery = session.Query<Entity>(); | ||
Assert.That(() => allQuery.ToListAsync(), Has.Count.EqualTo(1)); | ||
await (transaction.CommitAsync()); | ||
} | ||
} | ||
} |