16
16
namespace NHibernate . Test . NHSpecificTest . GH1180
17
17
{
18
18
using System . Threading . Tasks ;
19
- [ KnownBug ( " NH-3847 (GH-1180)" ) ]
19
+ // NH-3847 (GH-1180)
20
20
[ TestFixture ]
21
21
public class ByCodeFixtureAsync : TestCaseMappingByCode
22
22
{
@@ -27,7 +27,7 @@ protected override HbmMapping GetMappings()
27
27
mapper . Class < Entity > ( rc =>
28
28
{
29
29
rc . Id ( x => x . Id , m => m . Generator ( Generators . GuidComb ) ) ;
30
- rc . Property ( x => x . Name , m => { m . Length ( 10 ) ; } ) ;
30
+ rc . Property ( x => x . Name , m => { m . Type ( NHibernateUtil . AnsiString ) ; m . Length ( 5 ) ; } ) ;
31
31
rc . Property ( x => x . Amount , m => { m . Precision ( 8 ) ; m . Scale ( 2 ) ; } ) ;
32
32
} ) ;
33
33
@@ -58,39 +58,40 @@ public async Task StringTypesAsync()
58
58
await ( transaction . CommitAsync ( ) ) ;
59
59
}
60
60
61
- // whenTrue is constant, whenFalse is property -> works even before the fix
61
+ // whenTrue is constant, whenFalse is property
62
62
using ( var session = OpenSession ( ) )
63
63
{
64
64
ICriteria tagCriteria = session . CreateCriteria ( typeof ( Entity ) ) ;
65
65
66
66
var conditionalProjection = Projections . Conditional (
67
67
Restrictions . Not (
68
68
Restrictions . Like ( nameof ( Entity . Name ) , "B%" ) ) ,
69
- Projections . Constant ( "other" ) ,
69
+ //Property - ansi string length 5; contstant - string, length 10
70
+ Projections . Constant ( "otherstring" ) ,
70
71
Projections . Property ( nameof ( Entity . Name ) ) ) ;
71
72
tagCriteria . SetProjection ( conditionalProjection ) ;
72
73
73
74
// run query
74
75
var results = await ( tagCriteria . ListAsync ( ) ) ;
75
76
76
- Assert . That ( results , Is . EquivalentTo ( new [ ] { "other " , "Beta" , "other " } ) ) ;
77
+ Assert . That ( results , Is . EquivalentTo ( new [ ] { "otherstring " , "Beta" , "otherstring " } ) ) ;
77
78
}
78
79
79
- // whenTrue is property, whenFalse is constant -> fails before the fix
80
+ // whenTrue is property, whenFalse is constant
80
81
using ( var session = OpenSession ( ) )
81
82
{
82
83
ICriteria tagCriteria = session . CreateCriteria ( typeof ( Entity ) ) ;
83
84
84
85
var conditionalProjection = Projections . Conditional (
85
86
Restrictions . Like ( nameof ( Entity . Name ) , "B%" ) ,
86
87
Projections . Property ( nameof ( Entity . Name ) ) ,
87
- Projections . Constant ( "other " ) ) ;
88
+ Projections . Constant ( "otherstring " ) ) ;
88
89
tagCriteria . SetProjection ( conditionalProjection ) ;
89
90
90
91
// run query
91
92
var results = await ( tagCriteria . ListAsync ( ) ) ;
92
93
93
- Assert . That ( results , Is . EquivalentTo ( new [ ] { "other " , "Beta" , "other " } ) ) ;
94
+ Assert . That ( results , Is . EquivalentTo ( new [ ] { "otherstring " , "Beta" , "otherstring " } ) ) ;
94
95
}
95
96
}
96
97
@@ -100,46 +101,47 @@ public async Task DecimalTypesAsync()
100
101
using ( var session = OpenSession ( ) )
101
102
using ( var transaction = session . BeginTransaction ( ) )
102
103
{
103
- await ( session . SaveAsync ( new Entity { Amount = 3.14m } ) ) ;
104
- await ( session . SaveAsync ( new Entity { Amount = 42.13m } ) ) ;
105
- await ( session . SaveAsync ( new Entity { Amount = 17.99m } ) ) ;
104
+ await ( session . SaveAsync ( new Entity { Amount = 3.141m } ) ) ;
105
+ await ( session . SaveAsync ( new Entity { Amount = 42.131m } ) ) ;
106
+ await ( session . SaveAsync ( new Entity { Amount = 17.991m } ) ) ;
106
107
107
108
await ( transaction . CommitAsync ( ) ) ;
108
109
}
109
110
110
- // whenTrue is constant, whenFalse is property -> works even before the fix
111
+ // whenTrue is constant, whenFalse is property
111
112
using ( var session = OpenSession ( ) )
112
113
{
113
114
ICriteria tagCriteria = session . CreateCriteria ( typeof ( Entity ) ) ;
114
115
115
116
var conditionalProjection = Projections . Conditional (
116
117
Restrictions . Not (
117
118
Restrictions . Ge ( nameof ( Entity . Amount ) , 20m ) ) ,
118
- Projections . Constant ( 20m ) ,
119
+ //Property scale is 2, make sure constant scale 3 is not lost
120
+ Projections . Constant ( 20.123m ) ,
119
121
Projections . Property ( nameof ( Entity . Amount ) ) ) ;
120
122
tagCriteria . SetProjection ( conditionalProjection ) ;
121
123
122
124
// run query
123
125
var results = await ( tagCriteria . ListAsync ( ) ) ;
124
126
125
- Assert . That ( results , Is . EquivalentTo ( new [ ] { 20m , 42.13m , 20m } ) ) ;
127
+ Assert . That ( results , Is . EquivalentTo ( new [ ] { 20.123m , 42.13m , 20.123m } ) ) ;
126
128
}
127
129
128
- // whenTrue is property, whenFalse is constant -> fails before the fix
130
+ // whenTrue is property, whenFalse is constant
129
131
using ( var session = OpenSession ( ) )
130
132
{
131
133
ICriteria tagCriteria = session . CreateCriteria ( typeof ( Entity ) ) ;
132
134
133
135
var conditionalProjection = Projections . Conditional (
134
136
Restrictions . Ge ( nameof ( Entity . Amount ) , 20m ) ,
135
137
Projections . Property ( nameof ( Entity . Amount ) ) ,
136
- Projections . Constant ( 20m ) ) ;
138
+ Projections . Constant ( 20.123m ) ) ;
137
139
tagCriteria . SetProjection ( conditionalProjection ) ;
138
140
139
141
// run query
140
142
var results = await ( tagCriteria . ListAsync ( ) ) ;
141
143
142
- Assert . That ( results , Is . EquivalentTo ( new [ ] { 20m , 42.13m , 20m } ) ) ;
144
+ Assert . That ( results , Is . EquivalentTo ( new [ ] { 20.123m , 42.13m , 20.123m } ) ) ;
143
145
}
144
146
}
145
147
}
0 commit comments