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 May 23, 2024
1 parent 8d6ed24 commit ca798c8
Show file tree
Hide file tree
Showing 38 changed files with 22 additions and 1,764 deletions.
52 changes: 0 additions & 52 deletions src/NHibernate.Test/Async/Linq/ByMethod/MappedAsTests.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/NHibernate.Test/Async/Linq/WhereTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,6 @@ where sheet.Users.Select(x => new { Id = x.Id, Name = x.Name }).Any(x => x.Id ==
Assert.That(query.Count, Is.EqualTo(2));
}

[Test]
public async Task ContainsSubqueryWithCoalesceStringEnumSelectAsync()
{
if (Dialect is MsSqlCeDialect || Dialect is SQLiteDialect)
Assert.Ignore("Dialect is not supported");

var results =
await (db.Timesheets.Where(
o =>
o.Users
.Where(u => u.Id != 0.MappedAs(NHibernateUtil.Int32))
.Select(u => u.Name == u.Name ? u.Enum1 : u.NullableEnum1.Value)
.Contains(EnumStoredAsString.Small))
.ToListAsync());

Assert.That(results.Count, Is.EqualTo(1));
}

[Test]
public async Task SearchOnObjectTypeWithExtensionMethodAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
namespace NHibernate.Test.NHSpecificTest.Dates
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class DateTimeOffsetFixtureAsync : FixtureBaseAsync
{
Expand Down Expand Up @@ -76,22 +75,5 @@ public async Task SavingAndRetrievingTestAsync()
await (tx.CommitAsync());
}
}

[Test]
public async Task NextAsync()
{
var type = NHibernateUtil.DateTimeOffset;
var current = DateTimeOffset.Now.AddTicks(-1);
object next = await (type.NextAsync(current, null, CancellationToken.None));

Assert.That(next, Is.TypeOf<DateTimeOffset>().And.Property("Ticks").GreaterThan(current.Ticks));
}

[Test]
public async Task SeedAsync()
{
var type = NHibernateUtil.DateTimeOffset;
Assert.That(await (type.SeedAsync(null, CancellationToken.None)), Is.TypeOf<DateTimeOffset>());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,103 +65,6 @@ protected override void OnTearDown()
CultureInfo.CurrentUICulture = _backupUICulture;
}

// Non-reg test case
[Test]
public async Task NonNullableMappedAsDateShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == _testDate.MappedAs(NHibernateUtil.Date))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Non-reg test case
[Test]
public async Task NonNullableMappedAsDateShouldIgnoreTimeAsync()
{
using (ISession session = OpenSession())
{
var result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == _testDate.AddMinutes(10).MappedAs(NHibernateUtil.Date))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Non-reg test case
[Test]
public async Task NonNullableMappedAsDateTimeShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == _testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Non-reg test case
[Test]
[Obsolete]
public async Task NonNullableMappedAsTimestampShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == _testDate.MappedAs(NHibernateUtil.Timestamp))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Non-reg test case
[Test]
public async Task NonNullableParameterValueShouldNotBeCachedWithMappedAsAndAsync()
{
// Dodges the query parameter formatting bug for showcasing the parameter value bug
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
try
{
using (ISession session = OpenSession())
{
var result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == _testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);

var testDate = _testDate.AddMinutes(10);
result = await (session.Query<Entity>()
.Where(e => e.NonNullableDateTime == testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

CollectionAssert.IsEmpty(result);
}
}
finally
{
CultureInfo.CurrentCulture = _testCulture;
CultureInfo.CurrentUICulture = _testCulture;
}
}

// Non-reg test case
[Test]
public async Task NonNullableShouldBeCultureAgnosticAsync()
Expand All @@ -178,104 +81,6 @@ public async Task NonNullableShouldBeCultureAgnosticAsync()
}
}

// Failing test case till NH-3961 is fixed
[Test]
public async Task NullableMappedAsDateShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == _testDate.MappedAs(NHibernateUtil.Date))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Failing test case till NH-3961 is fixed
[Test]
public async Task NullableMappedAsDateShouldIgnoreTimeAsync()
{
var testDate = _testDate.AddMinutes(10);
using (ISession session = OpenSession())
{
var result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == testDate.MappedAs(NHibernateUtil.Date))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Failing test case till NH-3961 is fixed
[Test]
public async Task NullableMappedAsDateTimeShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == _testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Failing test case till NH-3961 is fixed
[Test]
[Obsolete]
public async Task NullableMappedAsTimestampShouldBeCultureAgnosticAsync()
{
using (ISession session = OpenSession())
using (session.BeginTransaction())
{
var result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == _testDate.MappedAs(NHibernateUtil.Timestamp))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);
}
}

// Failing test case till NH-3961 is fixed
[Test]
public async Task NullableParameterValueShouldNotBeCachedWithMappedAsAsync()
{
// Dodges the query parameter formatting bug for showcasing the parameter value bug
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
try
{
using (ISession session = OpenSession())
{
var result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == _testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

Assert.AreEqual(1, result.Count);
Assert.AreEqual("Bob", result[0].Name);

var testDate = _testDate.AddMinutes(10);
result = await (session.Query<Entity>()
.Where(e => e.NullableDateTime == testDate.MappedAs(NHibernateUtil.DateTime))
.ToListAsync());

CollectionAssert.IsEmpty(result);
}
}
finally
{
CultureInfo.CurrentCulture = _testCulture;
CultureInfo.CurrentUICulture = _testCulture;
}
}

// Non-reg test case
[Test]
public async Task NullableShouldBeCultureAgnosticAsync()
Expand Down
28 changes: 0 additions & 28 deletions src/NHibernate.Test/Async/TypesTest/AbstractDateTimeTypeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
namespace NHibernate.Test.TypesTest
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public abstract class AbstractDateTimeTypeFixtureAsync : TypeFixtureBase
{
Expand Down Expand Up @@ -81,33 +80,6 @@ protected override void DropSchema()
base.DropSchema();
}

[Test]
public async Task NextAsync()
{
// Take some margin, as DbTimestampType takes its next value from the database, which
// may have its clock a bit shifted even if running on the same server. (Seen with PostgreSQL,
// off by a few seconds, and with SAP HANA running in a vm, off by twenty seconds.)
var current = Now.Subtract(TimeSpan.FromMinutes(2));
var next = await (Type.NextAsync(current, null, CancellationToken.None));

Assert.That(next, Is.TypeOf<DateTime>(), "next should be DateTime");
Assert.That(next, Is.GreaterThan(current), "next should be greater than current");
}

[Test]
public async Task SeedAsync()
{
Assert.That(await (Type.SeedAsync(null, CancellationToken.None)), Is.TypeOf<DateTime>(), "seed should be DateTime");
}

[Test]
public async Task ComparerAsync()
{
var v1 = await (Type.SeedAsync(null, CancellationToken.None));
var v2 = Now.Subtract(TimeSpan.FromTicks(DateAccuracyInTicks));
Assert.That(() => Type.Comparator.Compare(v1, v2), Throws.Nothing);
}

[Test]
[TestCase(DateTimeKind.Unspecified)]
[TestCase(DateTimeKind.Local)]
Expand Down
17 changes: 0 additions & 17 deletions src/NHibernate.Test/Async/TypesTest/DateTimeOffsetTypeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
namespace NHibernate.Test.TypesTest
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class DateTimeOffsetTypeFixtureAsync : TypeFixtureBase
{
Expand Down Expand Up @@ -75,22 +74,6 @@ protected override void DropSchema()
base.DropSchema();
}

[Test]
public async Task NextAsync()
{
var current = DateTimeOffset.Parse("2004-01-01");
var next = await (Type.NextAsync(current, null, CancellationToken.None));

Assert.That(next, Is.TypeOf<DateTimeOffset>(), "next should be DateTimeOffset");
Assert.That(next, Is.GreaterThan(current), "next should be greater than current");
}

[Test]
public async Task SeedAsync()
{
Assert.That(await (Type.SeedAsync(null, CancellationToken.None)), Is.TypeOf<DateTimeOffset>(), "seed should be DateTime");
}

[Test]
public async Task ReadWriteAsync()
{
Expand Down

0 comments on commit ca798c8

Please sign in to comment.