Skip to content

Commit bf5bb34

Browse files
committed
Revert test changes. Added formula.
1 parent 20d453a commit bf5bb34

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/NHibernate.Test/Async/Linq/EnumTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ namespace NHibernate.Test.Linq
2121
{
2222
using System.Threading.Tasks;
2323
using System.Threading;
24-
[TestFixture(typeof(EnumType<TestEnum>))]
25-
[TestFixture(typeof(EnumStringType<TestEnum>))]
26-
[TestFixture(typeof(EnumAnsiStringType<TestEnum>))]
24+
[TestFixture(typeof(EnumType<TestEnum>),"0")]
25+
[TestFixture(typeof(EnumStringType<TestEnum>), "'Unspecified'")]
26+
[TestFixture(typeof(EnumAnsiStringType<TestEnum>), "'Unspecified'")]
2727
public class EnumTestsAsync : TestCaseMappingByCode
2828
{
2929
private IType _enumType;
30+
private string _unspecifiedValue;
3031

31-
32-
public EnumTestsAsync(System.Type enumType)
32+
public EnumTestsAsync(System.Type enumType, string unspecifiedValue)
3333
{
3434
_enumType = (IType) Activator.CreateInstance(enumType);
35+
_unspecifiedValue = unspecifiedValue;
3536
}
3637

3738
protected override HbmMapping GetMappings()
@@ -44,7 +45,11 @@ protected override HbmMapping GetMappings()
4445
rc.Id(x => x.Id, m => m.Generator(Generators.Identity));
4546
rc.Property(x => x.Name);
4647
rc.Property(x => x.Enum, m => m.Type(_enumType));
47-
rc.Property(x => x.NullableEnum, m => m.Type(_enumType));
48+
rc.Property(x => x.NullableEnum, m =>
49+
{
50+
m.Type(_enumType);
51+
m.Formula($"(case when Enum = {_unspecifiedValue} then null else Enum end)");
52+
});
4853
rc.ManyToOne(x => x.Other, m => m.Cascade(Mapping.ByCode.Cascade.All));
4954
});
5055

src/NHibernate.Test/Linq/EnumTests.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88

99
namespace NHibernate.Test.Linq
1010
{
11-
[TestFixture(typeof(EnumType<TestEnum>))]
12-
[TestFixture(typeof(EnumStringType<TestEnum>))]
13-
[TestFixture(typeof(EnumAnsiStringType<TestEnum>))]
11+
[TestFixture(typeof(EnumType<TestEnum>),"0")]
12+
[TestFixture(typeof(EnumStringType<TestEnum>), "'Unspecified'")]
13+
[TestFixture(typeof(EnumAnsiStringType<TestEnum>), "'Unspecified'")]
1414
public class EnumTests : TestCaseMappingByCode
1515
{
1616
private IType _enumType;
17+
private string _unspecifiedValue;
1718

18-
19-
public EnumTests(System.Type enumType)
19+
public EnumTests(System.Type enumType, string unspecifiedValue)
2020
{
2121
_enumType = (IType) Activator.CreateInstance(enumType);
22+
_unspecifiedValue = unspecifiedValue;
2223
}
2324

2425
protected override HbmMapping GetMappings()
@@ -31,7 +32,11 @@ protected override HbmMapping GetMappings()
3132
rc.Id(x => x.Id, m => m.Generator(Generators.Identity));
3233
rc.Property(x => x.Name);
3334
rc.Property(x => x.Enum, m => m.Type(_enumType));
34-
rc.Property(x => x.NullableEnum, m => m.Type(_enumType));
35+
rc.Property(x => x.NullableEnum, m =>
36+
{
37+
m.Type(_enumType);
38+
m.Formula($"(case when Enum = {_unspecifiedValue} then null else Enum end)");
39+
});
3540
rc.ManyToOne(x => x.Other, m => m.Cascade(Mapping.ByCode.Cascade.All));
3641
});
3742

0 commit comments

Comments
 (0)