Skip to content

Commit 8b59014

Browse files
Generate async files
1 parent b9e8e74 commit 8b59014

File tree

1 file changed

+102
-0
lines changed
  • src/NHibernate.Test/Async/NHSpecificTest/GH3530

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Globalization;
13+
using NUnit.Framework;
14+
15+
namespace NHibernate.Test.NHSpecificTest.GH3530
16+
{
17+
using System.Threading.Tasks;
18+
[TestFixture]
19+
public class FixtureAsync : BugTestCase
20+
{
21+
private CultureInfo initialCulture;
22+
23+
[OneTimeSetUp]
24+
public void FixtureSetup()
25+
{
26+
initialCulture = CurrentCulture;
27+
}
28+
29+
[OneTimeTearDown]
30+
public void FixtureTearDown()
31+
{
32+
CurrentCulture = initialCulture;
33+
}
34+
35+
protected override void OnTearDown()
36+
{
37+
using (var session = OpenSession())
38+
using (var transaction = session.BeginTransaction())
39+
{
40+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
41+
42+
transaction.Commit();
43+
}
44+
}
45+
46+
[TestCaseSource(nameof(GetTestCases))]
47+
public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
48+
{
49+
DateTime leapDay = new DateTime(2024, 2, 29, new GregorianCalendar(GregorianCalendarTypes.USEnglish));
50+
double doubleValue = 12.3f;
51+
int intValue = 4;
52+
object id;
53+
54+
CurrentCulture = from;
55+
using (var session = OpenSession())
56+
using (var tx = session.BeginTransaction())
57+
{
58+
var entity = new LocaleEntity()
59+
{
60+
DateTimeValue = leapDay,
61+
DoubleValue = doubleValue,
62+
IntegerValue = intValue,
63+
};
64+
65+
id = await (session.SaveAsync(entity));
66+
await (tx.CommitAsync());
67+
}
68+
69+
CurrentCulture = to;
70+
using (var session = OpenSession())
71+
using (var tx = session.BeginTransaction())
72+
{
73+
var entity = await (session.GetAsync<LocaleEntity>(id));
74+
75+
Assert.AreEqual(leapDay, entity.DateTimeValue);
76+
Assert.AreEqual(intValue, entity.IntegerValue);
77+
Assert.True(doubleValue - entity.DoubleValue < double.Epsilon);
78+
}
79+
}
80+
81+
private CultureInfo CurrentCulture
82+
{
83+
get
84+
{
85+
return CultureInfo.CurrentCulture;
86+
}
87+
set
88+
{
89+
CultureInfo.CurrentCulture = value;
90+
}
91+
}
92+
93+
public static object[][] GetTestCases()
94+
{
95+
return [
96+
[new CultureInfo("en-US"), new CultureInfo("de-DE")],
97+
[new CultureInfo("en-US"), new CultureInfo("ar-SA", false)],
98+
[new CultureInfo("en-US"), new CultureInfo("th-TH", false)],
99+
];
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)