-
Notifications
You must be signed in to change notification settings - Fork 930
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
bc7e5c3
commit 69d1442
Showing
2 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
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
85 changes: 85 additions & 0 deletions
85
src/NHibernate.Test/Async/NHSpecificTest/NH750/ManyToManyThrowsForNotFoundFixture.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,85 @@ | ||
//------------------------------------------------------------------------------ | ||
// <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.Linq; | ||
using NHibernate.Criterion; | ||
using NHibernate.Linq; | ||
using NHibernate.Transform; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.NH750 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class ManyToManyThrowsForNotFoundFixtureAsync : BugTestCase | ||
{ | ||
private int _id; | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (var s = Sfi.OpenSession()) | ||
using (var t = s.BeginTransaction()) | ||
{ | ||
Device dv = new Device("Device"); | ||
Drive dr = new Drive("Drive"); | ||
s.Save(dr); | ||
dv.DrivesNotIgnored.Add(dr); | ||
|
||
_id = (int) s.Save(dv); | ||
s.Flush(); | ||
|
||
s.Clear(); | ||
s.Delete(dr); | ||
t.Commit(); | ||
} | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var t = s.BeginTransaction()) | ||
{ | ||
s.Delete("from Device"); | ||
s.Delete("from Drive"); | ||
t.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task LazyLoadAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var device = await (s.GetAsync<Device>(_id)); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(() => NHibernateUtil.InitializeAsync(device.DrivesNotIgnored)); | ||
} | ||
|
||
[Test] | ||
public void QueryOverFetchAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var queryOver = s.QueryOver<Device>() | ||
.Fetch(SelectMode.Fetch, x => x.DrivesNotIgnored) | ||
.Where(Restrictions.IdEq(_id)) | ||
.TransformUsing(Transformers.DistinctRootEntity); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (queryOver.SingleOrDefaultAsync())))); | ||
} | ||
|
||
[Test] | ||
public void LinqFetchAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var query = s.Query<Device>() | ||
|
||
.Fetch(x => x.DrivesNotIgnored) | ||
.Where(x => x.Id == _id); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (query.SingleOrDefaultAsync())))); | ||
} | ||
} | ||
} |