@@ -88,7 +88,7 @@ protected override void DropSchema()
8888 [ Test ]
8989 public async Task NextAsync ( )
9090 {
91- var current = DateTime . Parse ( "2004-01-01" ) ;
91+ var current = Now . Subtract ( TimeSpan . FromTicks ( DateAccuracyInTicks ) ) ;
9292 var next = await ( Type . NextAsync ( current , null , CancellationToken . None ) ) ;
9393
9494 Assert . That ( next , Is . TypeOf < DateTime > ( ) , "next should be DateTime" ) ;
@@ -101,6 +101,14 @@ public async Task SeedAsync()
101101 Assert . That ( await ( Type . SeedAsync ( null , CancellationToken . None ) ) , Is . TypeOf < DateTime > ( ) , "seed should be DateTime" ) ;
102102 }
103103
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+
104112 [ Test ]
105113 [ TestCase ( DateTimeKind . Unspecified ) ]
106114 [ TestCase ( DateTimeKind . Local ) ]
@@ -322,6 +330,37 @@ public virtual async Task QueryUseExpectedSqlTypeAsync()
322330 AssertSqlType ( driver , 5 , true ) ;
323331 }
324332
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+
325364 private void AssertSqlType ( ClientDriverWithParamsStats driver , int expectedCount , bool exactType )
326365 {
327366 var typeSqlTypes = Type . SqlTypes ( Sfi ) ;
@@ -369,6 +408,19 @@ private void AssertSqlType(ClientDriverWithParamsStats driver, int expectedCount
369408 Assert . That ( driver . GetCount ( DbType . DateTime ) , Is . EqualTo ( 0 ) , "Found unexpected DbType.DateTime usages." ) ;
370409 Assert . That ( driver . GetCount ( DbType . Date ) , Is . EqualTo ( expectedCount ) , "Unexpected DbType.Date usage count." ) ;
371410 }
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+ }
372424 else
373425 {
374426 Assert . Ignore ( "Test does not involve tested types" ) ;
0 commit comments