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 15, 2024
1 parent de574f0 commit 2c75302
Showing 1 changed file with 89 additions and 8 deletions.
97 changes: 89 additions & 8 deletions src/NHibernate.Test/Async/NHSpecificTest/GH3530/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace NHibernate.Test.NHSpecificTest.GH3530
{
using System.Threading.Tasks;
using System.Threading;
[TestFixture]
public class FixtureAsync : BugTestCase
{
Expand Down Expand Up @@ -117,12 +118,10 @@ private string GetQualifiedName(string catalog, string schema, string name)
return Dialect.Qualify(catalog, schema, name);
}

[TestCaseSource(nameof(GetTestCases))]
public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
[Test, TestCaseSource(nameof(GetTestCases))]
public async Task TestDateTimeAsync(CultureInfo from, CultureInfo to)
{
DateTime leapDay = new DateTime(2024, 2, 29, new GregorianCalendar(GregorianCalendarTypes.USEnglish));
double doubleValue = 12.3f;
int intValue = 4;
object id;

CurrentCulture = from;
Expand All @@ -131,9 +130,7 @@ public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
{
var entity = new LocaleEntity()
{
DateTimeValue = leapDay,
DoubleValue = doubleValue,
IntegerValue = intValue,
DateTimeValue = leapDay
};

id = await (session.SaveAsync(entity));
Expand All @@ -147,11 +144,95 @@ public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
var entity = await (session.GetAsync<LocaleEntity>(id));

Assert.AreEqual(leapDay, entity.DateTimeValue);
Assert.AreEqual(intValue, entity.IntegerValue);
}
}

[Test, TestCaseSource(nameof(GetTestCases))]
public async Task TestDecimalAsync(CultureInfo from, CultureInfo to)
{
decimal decimalValue = 12.3m;
object id;

CurrentCulture = from;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = new LocaleEntity()
{
DecimalValue = decimalValue
};

id = await (session.SaveAsync(entity));
await (tx.CommitAsync());
}

CurrentCulture = to;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = await (session.GetAsync<LocaleEntity>(id));

Assert.AreEqual(decimalValue, entity.DecimalValue);
}
}

[Test, TestCaseSource(nameof(GetTestCases))]
public async Task TestDoubleAsync(CultureInfo from, CultureInfo to)
{
double doubleValue = 12.3d;
object id;

CurrentCulture = from;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = new LocaleEntity()
{
DoubleValue = doubleValue
};

id = await (session.SaveAsync(entity));
await (tx.CommitAsync());
}

CurrentCulture = to;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = await (session.GetAsync<LocaleEntity>(id));

Assert.True(doubleValue - entity.DoubleValue < double.Epsilon);
}
}

public async Task TestIntegerAsync(CultureInfo from, CultureInfo to, CancellationToken cancellationToken = default(CancellationToken))
{
int integerValue = 123;
object id;

CurrentCulture = from;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = new LocaleEntity()
{
IntegerValue = integerValue
};

id = await (session.SaveAsync(entity, cancellationToken));
await (tx.CommitAsync(cancellationToken));
}

CurrentCulture = to;
using (var session = OpenSession())
using (var tx = session.BeginTransaction())
{
var entity = await (session.GetAsync<LocaleEntity>(id, cancellationToken));

Assert.AreEqual(integerValue, entity.IntegerValue);
}
}

private CultureInfo CurrentCulture
{
get
Expand Down

0 comments on commit 2c75302

Please sign in to comment.