Skip to content

Commit 2c75302

Browse files
Generate async files
1 parent de574f0 commit 2c75302

File tree

1 file changed

+89
-8
lines changed
  • src/NHibernate.Test/Async/NHSpecificTest/GH3530

1 file changed

+89
-8
lines changed

src/NHibernate.Test/Async/NHSpecificTest/GH3530/Fixture.cs

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace NHibernate.Test.NHSpecificTest.GH3530
2020
{
2121
using System.Threading.Tasks;
22+
using System.Threading;
2223
[TestFixture]
2324
public class FixtureAsync : BugTestCase
2425
{
@@ -117,12 +118,10 @@ private string GetQualifiedName(string catalog, string schema, string name)
117118
return Dialect.Qualify(catalog, schema, name);
118119
}
119120

120-
[TestCaseSource(nameof(GetTestCases))]
121-
public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
121+
[Test, TestCaseSource(nameof(GetTestCases))]
122+
public async Task TestDateTimeAsync(CultureInfo from, CultureInfo to)
122123
{
123124
DateTime leapDay = new DateTime(2024, 2, 29, new GregorianCalendar(GregorianCalendarTypes.USEnglish));
124-
double doubleValue = 12.3f;
125-
int intValue = 4;
126125
object id;
127126

128127
CurrentCulture = from;
@@ -131,9 +130,7 @@ public async Task TestLocalesAsync(CultureInfo from, CultureInfo to)
131130
{
132131
var entity = new LocaleEntity()
133132
{
134-
DateTimeValue = leapDay,
135-
DoubleValue = doubleValue,
136-
IntegerValue = intValue,
133+
DateTimeValue = leapDay
137134
};
138135

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

149146
Assert.AreEqual(leapDay, entity.DateTimeValue);
150-
Assert.AreEqual(intValue, entity.IntegerValue);
147+
}
148+
}
149+
150+
[Test, TestCaseSource(nameof(GetTestCases))]
151+
public async Task TestDecimalAsync(CultureInfo from, CultureInfo to)
152+
{
153+
decimal decimalValue = 12.3m;
154+
object id;
155+
156+
CurrentCulture = from;
157+
using (var session = OpenSession())
158+
using (var tx = session.BeginTransaction())
159+
{
160+
var entity = new LocaleEntity()
161+
{
162+
DecimalValue = decimalValue
163+
};
164+
165+
id = await (session.SaveAsync(entity));
166+
await (tx.CommitAsync());
167+
}
168+
169+
CurrentCulture = to;
170+
using (var session = OpenSession())
171+
using (var tx = session.BeginTransaction())
172+
{
173+
var entity = await (session.GetAsync<LocaleEntity>(id));
174+
175+
Assert.AreEqual(decimalValue, entity.DecimalValue);
176+
}
177+
}
178+
179+
[Test, TestCaseSource(nameof(GetTestCases))]
180+
public async Task TestDoubleAsync(CultureInfo from, CultureInfo to)
181+
{
182+
double doubleValue = 12.3d;
183+
object id;
184+
185+
CurrentCulture = from;
186+
using (var session = OpenSession())
187+
using (var tx = session.BeginTransaction())
188+
{
189+
var entity = new LocaleEntity()
190+
{
191+
DoubleValue = doubleValue
192+
};
193+
194+
id = await (session.SaveAsync(entity));
195+
await (tx.CommitAsync());
196+
}
197+
198+
CurrentCulture = to;
199+
using (var session = OpenSession())
200+
using (var tx = session.BeginTransaction())
201+
{
202+
var entity = await (session.GetAsync<LocaleEntity>(id));
203+
151204
Assert.True(doubleValue - entity.DoubleValue < double.Epsilon);
152205
}
153206
}
154207

208+
public async Task TestIntegerAsync(CultureInfo from, CultureInfo to, CancellationToken cancellationToken = default(CancellationToken))
209+
{
210+
int integerValue = 123;
211+
object id;
212+
213+
CurrentCulture = from;
214+
using (var session = OpenSession())
215+
using (var tx = session.BeginTransaction())
216+
{
217+
var entity = new LocaleEntity()
218+
{
219+
IntegerValue = integerValue
220+
};
221+
222+
id = await (session.SaveAsync(entity, cancellationToken));
223+
await (tx.CommitAsync(cancellationToken));
224+
}
225+
226+
CurrentCulture = to;
227+
using (var session = OpenSession())
228+
using (var tx = session.BeginTransaction())
229+
{
230+
var entity = await (session.GetAsync<LocaleEntity>(id, cancellationToken));
231+
232+
Assert.AreEqual(integerValue, entity.IntegerValue);
233+
}
234+
}
235+
155236
private CultureInfo CurrentCulture
156237
{
157238
get

0 commit comments

Comments
 (0)