Skip to content

Commit

Permalink
Generate async files
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 16, 2023
1 parent bc7e5c3 commit 69d1442
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ protected override void OnTearDown()
}
}

protected override void Configure(Configuration configuration)
{
configuration.SetProperty(Cfg.Environment.UseSecondLevelCache, "false");
base.Configure(configuration);
}

[Test]
public async Task DeviceOfDriveAsync()
{
Expand Down
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()))));
}
}
}

0 comments on commit 69d1442

Please sign in to comment.