11using System ;
22using System . Data . SqlClient ;
33using System . Data . SqlTypes ;
4+ using System . Linq ;
45using NUnit . Framework ;
56using ServiceStack . DataAnnotations ;
67using ServiceStack . OrmLite . SqlServer ;
@@ -21,7 +22,6 @@ public void datetime_tests__can_use_datetime2()
2122
2223 using ( var conn = dbFactory . OpenDbConnection ( ) ) {
2324 var test_object_ValidForDatetime2 = Table_for_datetime2_tests . get_test_object_ValidForDatetime2 ( ) ;
24- var test_object_ValidForNormalDatetime = Table_for_datetime2_tests . get_test_object_ValidForNormalDatetime ( ) ;
2525
2626 conn . CreateTable < Table_for_datetime2_tests > ( true ) ;
2727
@@ -38,10 +38,13 @@ public void datetime_tests__can_use_datetime2()
3838 var fromDb2 = conn . SingleById < Table_for_datetime2_tests > ( insertedId ) ;
3939 Assert . AreEqual ( test_object_ValidForDatetime2 . ToVerifyPrecision . Value . AddYears ( 1 ) , fromDb2 . ToVerifyPrecision ) ;
4040
41-
4241 //check InsertParam
4342 conn . Insert ( test_object_ValidForDatetime2 ) ;
44- }
43+
44+ //check select on datetime2 value
45+ var result = conn . Select < Table_for_datetime2_tests > ( t => t . ToVerifyPrecision == test_object_ValidForDatetime2 . ToVerifyPrecision ) ;
46+ Assert . AreEqual ( result . Single ( ) . ToVerifyPrecision , test_object_ValidForDatetime2 . ToVerifyPrecision ) ;
47+ }
4548 }
4649 [ Test ]
4750 public void datetime_tests__check_default_behaviour ( )
@@ -89,10 +92,10 @@ private class Table_for_datetime2_tests
8992 public DateTime ? ToVerifyPrecision { get ; set ; }
9093 public DateTime ? NullableDateTimeLeaveItNull { get ; set ; }
9194
92- /// <summary>
93- /// to check datetime(2)'s precision. A regular 'datetime' is not precise enough
94- /// </summary>
95- public static readonly DateTime regular_datetime_field_cant_hold_this_exact_moment = new DateTime ( 2013 , 3 , 17 , 21 , 29 , 1 , 678 ) ;
95+ /// <summary>
96+ /// to check datetime(2)'s precision. A regular 'datetime' is not precise enough
97+ /// </summary>
98+ public static readonly DateTime regular_datetime_field_cant_hold_this_exact_moment = new DateTime ( 2013 , 3 , 17 , 21 , 29 , 1 , 678 ) . AddTicks ( 1 ) ;
9699
97100 public static Table_for_datetime2_tests get_test_object_ValidForDatetime2 ( ) { return new Table_for_datetime2_tests { SomeDateTime = new DateTime ( 1 , 1 , 1 ) , ToVerifyPrecision = regular_datetime_field_cant_hold_this_exact_moment } ; }
98101
0 commit comments