@@ -133,92 +133,160 @@ private void AssertFailedInsertExceptionDetailsAndEmptyTable(Exception ex)
133
133
[ Test ]
134
134
public void CriteriaLikeParameterCanExceedColumnSize ( )
135
135
{
136
- if ( sessions . ConnectionProvider . Driver is OdbcDriver )
137
- Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
136
+ Exception exception = CatchException < Exception > (
137
+ ( ) =>
138
+ {
139
+ using ( ISession s = OpenSession ( ) )
140
+ using ( s . BeginTransaction ( ) )
141
+ {
142
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
143
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
138
144
139
- using ( ISession s = OpenSession ( ) )
140
- using ( s . BeginTransaction ( ) )
141
- {
142
- s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
143
- s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
145
+ var aaItems =
146
+ s . CreateCriteria < StringClass > ( )
147
+ . Add ( Restrictions . Like ( "StringValue" , "%AAAAAAAAA%" ) )
148
+ . List ( ) ;
149
+
150
+ Assert . That ( aaItems . Count , Is . EqualTo ( 2 ) ) ;
151
+ }
152
+ } ) ;
144
153
145
- var aaItems =
146
- s . CreateCriteria < StringClass > ( )
147
- . Add ( Restrictions . Like ( "StringValue" , "%AAAAAAAAA%" ) )
148
- . List ( ) ;
149
154
150
- Assert . That ( aaItems . Count , Is . EqualTo ( 2 ) ) ;
151
- }
155
+ // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column.
156
+ AssertExpectedFailureOrNoException (
157
+ exception ,
158
+ ( sessions . ConnectionProvider . Driver is OdbcDriver ) ) ;
152
159
}
153
160
154
161
[ Test ]
155
162
public void HqlLikeParameterCanExceedColumnSize ( )
156
163
{
157
- if ( sessions . ConnectionProvider . Driver is OdbcDriver )
158
- Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
164
+ Exception exception = CatchException < Exception > (
165
+ ( ) =>
166
+ {
167
+ using ( ISession s = OpenSession ( ) )
168
+ using ( s . BeginTransaction ( ) )
169
+ {
170
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
171
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
159
172
160
- using ( ISession s = OpenSession ( ) )
161
- using ( s . BeginTransaction ( ) )
162
- {
163
- s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
164
- s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
173
+ var aaItems =
174
+ s . CreateQuery ( "from StringClass s where s.StringValue like :likeValue" )
175
+ . SetParameter ( "likeValue" , "%AAAAAAAAA%" )
176
+ . List ( ) ;
165
177
166
- var aaItems =
167
- s . CreateQuery ( "from StringClass s where s.StringValue like :likeValue" )
168
- . SetParameter ( "likeValue" , "%AAAAAAAAA%" )
169
- . List ( ) ;
178
+ Assert . That ( aaItems . Count , Is . EqualTo ( 2 ) ) ;
179
+ }
180
+ } ) ;
170
181
171
- Assert . That ( aaItems . Count , Is . EqualTo ( 2 ) ) ;
172
- }
182
+
183
+ // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column.
184
+ AssertExpectedFailureOrNoException (
185
+ exception ,
186
+ ( sessions . ConnectionProvider . Driver is OdbcDriver ) ) ;
173
187
}
174
188
175
189
176
190
[ Test ]
177
191
public void CriteriaEqualityParameterCanExceedColumnSize ( )
178
192
{
179
- if ( sessions . ConnectionProvider . Driver is OdbcDriver )
180
- Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
181
-
182
193
// We should be able to query a column with a value longer than
183
194
// the specified column size, to avoid tedious exceptions.
184
195
185
- using ( ISession s = OpenSession ( ) )
186
- using ( s . BeginTransaction ( ) )
187
- {
188
- s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
189
- s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
196
+ Exception exception = CatchException < Exception > (
197
+ ( ) =>
198
+ {
199
+ using ( ISession s = OpenSession ( ) )
200
+ using ( s . BeginTransaction ( ) )
201
+ {
202
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
203
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
190
204
191
- var aaItems =
192
- s . CreateCriteria < StringClass > ( )
193
- . Add ( Restrictions . Eq ( "StringValue" , "AAAAAAAAABx" ) )
194
- . List ( ) ;
205
+ var aaItems =
206
+ s . CreateCriteria < StringClass > ( )
207
+ . Add ( Restrictions . Eq ( "StringValue" , "AAAAAAAAABx" ) )
208
+ . List ( ) ;
195
209
196
- Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
197
- }
210
+ Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
211
+ }
212
+ } ) ;
213
+
214
+ // Doesn't work on Firebird due to Firebird not figuring out parameter types on its own.
215
+ // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column.
216
+ AssertExpectedFailureOrNoException (
217
+ exception ,
218
+ ( Dialect is FirebirdDialect ) || ( sessions . ConnectionProvider . Driver is OdbcDriver ) ) ;
198
219
}
199
220
221
+
200
222
[ Test ]
201
223
public void HqlEqualityParameterCanExceedColumnSize ( )
202
224
{
203
- if ( sessions . ConnectionProvider . Driver is OdbcDriver )
204
- Assert . Ignore ( "This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column." ) ;
205
-
206
225
// We should be able to query a column with a value longer than
207
226
// the specified column size, to avoid tedious exceptions.
208
227
209
- using ( ISession s = OpenSession ( ) )
210
- using ( s . BeginTransaction ( ) )
228
+ Exception exception = CatchException < Exception > (
229
+ ( ) =>
230
+ {
231
+ using ( ISession s = OpenSession ( ) )
232
+ using ( s . BeginTransaction ( ) )
233
+ {
234
+ s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
235
+ s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
236
+
237
+ var aaItems =
238
+ s . CreateQuery ( "from StringClass s where s.StringValue = :likeValue" )
239
+ . SetParameter ( "likeValue" , "AAAAAAAAABx" )
240
+ . List ( ) ;
241
+
242
+ Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
243
+ }
244
+ } ) ;
245
+
246
+ // Doesn't work on Firebird due to Firebird not figuring out parameter types on its own.
247
+ // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column.
248
+ AssertExpectedFailureOrNoException (
249
+ exception ,
250
+ ( Dialect is FirebirdDialect ) || ( sessions . ConnectionProvider . Driver is OdbcDriver ) ) ;
251
+ }
252
+
253
+
254
+ /// <summary>
255
+ /// Some test cases doesn't work during some scenarios for well-known reasons. If the test
256
+ /// fails under these circumstances, mark it as IGNORED. If it _stops_ failing, mark it
257
+ /// as a FAILURE so that it can be investigated.
258
+ /// </summary>
259
+ private void AssertExpectedFailureOrNoException ( Exception exception , bool requireExceptionAndIgnoreTest )
260
+ {
261
+ if ( requireExceptionAndIgnoreTest )
211
262
{
212
- s . Save ( new StringClass { Id = 1 , StringValue = "AAAAAAAAAB" } ) ;
213
- s . Save ( new StringClass { Id = 2 , StringValue = "BAAAAAAAAA" } ) ;
263
+ Assert . NotNull (
264
+ exception ,
265
+ "Test was expected to have a well-known, but ignored, failure for the current configuration. If " +
266
+ "that expected failure no longer occurs, it may now be possible to remove this exception." ) ;
267
+
268
+ Assert . Ignore ( "This test is known to fail for the current configuration." ) ;
269
+ }
270
+
271
+ // If the above didn't ignore the exception, it's for real - rethrow to trigger test failure.
272
+ if ( exception != null )
273
+ throw new Exception ( "Wrapped exception." , exception ) ;
274
+ }
214
275
215
- var aaItems =
216
- s . CreateQuery ( "from StringClass s where s.StringValue = :likeValue" )
217
- . SetParameter ( "likeValue" , "AAAAAAAAABx" )
218
- . List ( ) ;
219
276
220
- Assert . That ( aaItems . Count , Is . EqualTo ( 0 ) ) ;
277
+ private TException CatchException < TException > ( System . Action action )
278
+ where TException : Exception
279
+ {
280
+ try
281
+ {
282
+ action ( ) ;
221
283
}
284
+ catch ( TException exception )
285
+ {
286
+ return exception ;
287
+ }
288
+
289
+ return null ;
222
290
}
223
291
}
224
292
}
0 commit comments