@@ -88,7 +88,7 @@ protected override void DropSchema()
88
88
[ Test ]
89
89
public async Task NextAsync ( )
90
90
{
91
- var current = DateTime . Parse ( "2004-01-01" ) ;
91
+ var current = Now . Subtract ( TimeSpan . FromTicks ( DateAccuracyInTicks ) ) ;
92
92
var next = await ( Type . NextAsync ( current , null , CancellationToken . None ) ) ;
93
93
94
94
Assert . That ( next , Is . TypeOf < DateTime > ( ) , "next should be DateTime" ) ;
@@ -101,6 +101,14 @@ public async Task SeedAsync()
101
101
Assert . That ( await ( Type . SeedAsync ( null , CancellationToken . None ) ) , Is . TypeOf < DateTime > ( ) , "seed should be DateTime" ) ;
102
102
}
103
103
104
+ [ Test ]
105
+ public async Task ComparerAsync ( )
106
+ {
107
+ var v1 = await ( Type . SeedAsync ( null , CancellationToken . None ) ) ;
108
+ var v2 = Now . Subtract ( TimeSpan . FromTicks ( DateAccuracyInTicks ) ) ;
109
+ Assert . That ( ( ) => Type . Comparator . Compare ( v1 , v2 ) , Throws . Nothing ) ;
110
+ }
111
+
104
112
[ Test ]
105
113
[ TestCase ( DateTimeKind . Unspecified ) ]
106
114
[ TestCase ( DateTimeKind . Local ) ]
@@ -322,6 +330,37 @@ public virtual async Task QueryUseExpectedSqlTypeAsync()
322
330
AssertSqlType ( driver , 5 , true ) ;
323
331
}
324
332
333
+ /// <summary>
334
+ /// Tests if the type FromStringValue implementation behaves as expected.
335
+ /// </summary>
336
+ /// <param name="timestampValue"></param>
337
+ [ Test ]
338
+ [ TestCase ( "2011-01-27T15:50:59.6220000+02:00" ) ]
339
+ [ TestCase ( "2011-01-27T14:50:59.6220000+01:00" ) ]
340
+ [ TestCase ( "2011-01-27T13:50:59.6220000Z" ) ]
341
+ [ Obsolete ]
342
+ public virtual void FromStringValue_ParseValidValues ( string timestampValue )
343
+ {
344
+ var timestamp = DateTime . Parse ( timestampValue ) ;
345
+
346
+ Assert . That (
347
+ timestamp . Kind ,
348
+ Is . EqualTo ( DateTimeKind . Local ) ,
349
+ "Kind is NOT Local. dotnet framework parses datetime values with kind set to Local and " +
350
+ "time correct to local timezone." ) ;
351
+
352
+ var typeKind = GetTypeKind ( ) ;
353
+ if ( typeKind == DateTimeKind . Utc )
354
+ timestamp = timestamp . ToUniversalTime ( ) ;
355
+
356
+ var value = ( DateTime ) Type . FromStringValue ( timestampValue ) ;
357
+
358
+ Assert . That ( value , Is . EqualTo ( timestamp ) , timestampValue ) ;
359
+
360
+ if ( typeKind != DateTimeKind . Unspecified )
361
+ Assert . AreEqual ( GetTypeKind ( ) , value . Kind , "Unexpected FromStringValue kind" ) ;
362
+ }
363
+
325
364
private void AssertSqlType ( ClientDriverWithParamsStats driver , int expectedCount , bool exactType )
326
365
{
327
366
var typeSqlTypes = Type . SqlTypes ( Sfi ) ;
@@ -369,6 +408,19 @@ private void AssertSqlType(ClientDriverWithParamsStats driver, int expectedCount
369
408
Assert . That ( driver . GetCount ( DbType . DateTime ) , Is . EqualTo ( 0 ) , "Found unexpected DbType.DateTime usages." ) ;
370
409
Assert . That ( driver . GetCount ( DbType . Date ) , Is . EqualTo ( expectedCount ) , "Unexpected DbType.Date usage count." ) ;
371
410
}
411
+ else if ( typeSqlTypes . Any ( t => Equals ( t , SqlTypeFactory . Int64 ) ) )
412
+ {
413
+ Assert . That (
414
+ driver . GetCount ( SqlTypeFactory . DateTime ) ,
415
+ Is . EqualTo ( 0 ) ,
416
+ "Found unexpected SqlTypeFactory.DateTime usages." ) ;
417
+ Assert . That (
418
+ driver . GetCount ( SqlTypeFactory . Int64 ) ,
419
+ Is . EqualTo ( expectedCount ) ,
420
+ "Unexpected SqlTypeFactory.Int64 usage count." ) ;
421
+ Assert . That ( driver . GetCount ( DbType . DateTime ) , Is . EqualTo ( 0 ) , "Found unexpected DbType.DateTime usages." ) ;
422
+ Assert . That ( driver . GetCount ( DbType . Int64 ) , Is . EqualTo ( expectedCount ) , "Unexpected DbType.Int64 usage count." ) ;
423
+ }
372
424
else
373
425
{
374
426
Assert . Ignore ( "Test does not involve tested types" ) ;
0 commit comments