Skip to content

Commit

Permalink
nhibernateGH-3530: Break up the tests by type so we can see which typ…
Browse files Browse the repository at this point in the history
…es fail where.
  • Loading branch information
David Ellingsworth authored and David Ellingsworth committed May 15, 2024
1 parent 12dd8df commit de574f0
Showing 1 changed file with 88 additions and 8 deletions.
96 changes: 88 additions & 8 deletions src/NHibernate.Test/NHSpecificTest/GH3530/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ private string GetQualifiedName(string catalog, string schema, string name)
return Dialect.Qualify(catalog, schema, name);
}

[TestCaseSource(nameof(GetTestCases))]
public void TestLocales(CultureInfo from, CultureInfo to)
[Test, TestCaseSource(nameof(GetTestCases))]
public void TestDateTime(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 @@ -120,9 +118,7 @@ public void TestLocales(CultureInfo from, CultureInfo to)
{
var entity = new LocaleEntity()
{
DateTimeValue = leapDay,
DoubleValue = doubleValue,
IntegerValue = intValue,
DateTimeValue = leapDay
};

id = session.Save(entity);
Expand All @@ -136,11 +132,95 @@ public void TestLocales(CultureInfo from, CultureInfo to)
var entity = session.Get<LocaleEntity>(id);

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

[Test, TestCaseSource(nameof(GetTestCases))]
public void TestDecimal(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 = session.Save(entity);
tx.Commit();
}

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

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

[Test, TestCaseSource(nameof(GetTestCases))]
public void TestDouble(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 = session.Save(entity);
tx.Commit();
}

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

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

public void TestInteger(CultureInfo from, CultureInfo to)
{
int integerValue = 123;
object id;

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

id = session.Save(entity);
tx.Commit();
}

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

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

private CultureInfo CurrentCulture
{
get
Expand Down

0 comments on commit de574f0

Please sign in to comment.