@@ -241,10 +241,9 @@ public class ConversionNullalbeClass
241
241
242
242
public bool CompareObjectValues ( object x , object y , Type type )
243
243
{
244
- //handle string conversion.
245
- //by default behaviour for DvText is to be empty string, while for string is null.
246
- //so if we do roundtrip string-> DvText -> string all null string become empty strings.
247
- //therefore replace all null values to empty string if field is string.
244
+ // By default behaviour for DvText is to be empty string, while for string is null.
245
+ // So if we do roundtrip string-> DvText -> string all null string become empty strings.
246
+ // Therefore replace all null values to empty string if field is string.
248
247
if ( type == typeof ( string ) && x == null )
249
248
x = "" ;
250
249
if ( type == typeof ( string ) && y == null )
@@ -272,7 +271,6 @@ public bool CompareThrougReflection<T>(T x, T y)
272
271
if ( ! CompareObjectValues ( xvalue , yvalue , field . FieldType ) )
273
272
return false ;
274
273
}
275
-
276
274
}
277
275
return true ;
278
276
}
@@ -323,9 +321,9 @@ public void BackAndForthConversionWithBasicTypes()
323
321
new ConversionNullalbeClass ( ) { fInt = int . MaxValue , fuInt = uint . MaxValue , fBool = true , fsByte = sbyte . MaxValue , fByte = byte . MaxValue ,
324
322
fDouble = double . MaxValue , fFloat = float . MaxValue , fLong = long . MaxValue , fuLong = ulong . MaxValue ,
325
323
fShort = short . MaxValue , fuShort = ushort . MaxValue , fString = "ooh" } ,
326
- new ConversionNullalbeClass ( ) { fInt = int . MinValue + 1 , fuInt = uint . MinValue + 1 , fBool = true , fsByte = sbyte . MinValue + 1 , fByte = byte . MinValue + 1 ,
327
- fDouble = double . MinValue + 1 , fFloat = float . MinValue + 1 , fLong = long . MinValue + 1 , fuLong = ulong . MinValue + 1 ,
328
- fShort = short . MinValue + 1 , fuShort = ushort . MinValue + 1 , fString = "" } ,
324
+ new ConversionNullalbeClass ( ) { fInt = int . MinValue + 1 , fuInt = uint . MinValue , fBool = false , fsByte = sbyte . MinValue + 1 , fByte = byte . MinValue ,
325
+ fDouble = double . MinValue + 1 , fFloat = float . MinValue + 1 , fLong = long . MinValue + 1 , fuLong = ulong . MinValue ,
326
+ fShort = short . MinValue + 1 , fuShort = ushort . MinValue , fString = "" } ,
329
327
new ConversionNullalbeClass ( )
330
328
} ;
331
329
@@ -406,10 +404,8 @@ public void ConversionMinValueToNullBehavior()
406
404
new ConversionLossMinValueClass ( ) { fSByte = null , fInt = null , fLong = null , fShort = null } ,
407
405
new ConversionLossMinValueClass ( ) { fSByte = sbyte . MinValue , fInt = int . MinValue , fLong = long . MinValue , fShort = short . MinValue }
408
406
} ;
409
-
410
407
foreach ( var field in typeof ( ConversionLossMinValueClass ) . GetFields ( ) )
411
408
{
412
-
413
409
var dataView = ComponentCreation . CreateDataView ( env , data ) ;
414
410
var enumerator = dataView . AsEnumerable < ConversionLossMinValueClass > ( env , false ) . GetEnumerator ( ) ;
415
411
while ( enumerator . MoveNext ( ) )
@@ -430,16 +426,14 @@ public void ClassWithConstFieldsConversion()
430
426
new ClassWithConstField ( ) { fInt = - 1 , fString = "" } ,
431
427
new ClassWithConstField ( ) { fInt = 0 , fString = null }
432
428
} ;
429
+
433
430
using ( var env = new TlcEnvironment ( ) )
434
431
{
435
432
var dataView = ComponentCreation . CreateDataView ( env , data ) ;
436
433
var enumeratorSimple = dataView . AsEnumerable < ClassWithConstField > ( env , false ) . GetEnumerator ( ) ;
437
-
438
434
var originalEnumerator = data . GetEnumerator ( ) ;
439
435
while ( enumeratorSimple . MoveNext ( ) && originalEnumerator . MoveNext ( ) )
440
- {
441
436
Assert . True ( CompareThrougReflection ( enumeratorSimple . Current , originalEnumerator . Current ) ) ;
442
- }
443
437
Assert . True ( ! enumeratorSimple . MoveNext ( ) && ! originalEnumerator . MoveNext ( ) ) ;
444
438
}
445
439
}
@@ -459,6 +453,7 @@ public class ClassWithArrays
459
453
public double [ ] fDouble ;
460
454
public bool [ ] fBool ;
461
455
}
456
+
462
457
public class ClassWithNullableArrays
463
458
{
464
459
public string [ ] fString ;
@@ -475,7 +470,6 @@ public class ClassWithNullableArrays
475
470
public bool ? [ ] fBool ;
476
471
}
477
472
478
-
479
473
[ Fact ]
480
474
public void BackAndForthConversionWithArrays ( )
481
475
{
@@ -500,6 +494,7 @@ public void BackAndForthConversionWithArrays()
500
494
new ClassWithNullableArrays ( ) { fInt = new int ? [ 3 ] { - 2 , 1 , 0 } , fFloat = new float ? [ 3 ] { 0.99f , 0f , - 0.99f } , fString = new string [ 2 ] { "lola" , "hola" } } ,
501
495
new ClassWithNullableArrays ( )
502
496
} ;
497
+
503
498
using ( var env = new TlcEnvironment ( ) )
504
499
{
505
500
var dataView = ComponentCreation . CreateDataView ( env , data ) ;
@@ -521,7 +516,5 @@ public void BackAndForthConversionWithArrays()
521
516
Assert . True ( ! enumeratorNullable . MoveNext ( ) && ! originalNullalbleEnumerator . MoveNext ( ) ) ;
522
517
}
523
518
}
524
-
525
-
526
519
}
527
520
}
0 commit comments