1
1
using System ;
2
2
using System . Data . SqlClient ;
3
3
using System . Data . SqlTypes ;
4
+ using System . Linq ;
4
5
using NUnit . Framework ;
5
6
using ServiceStack . DataAnnotations ;
6
7
using ServiceStack . OrmLite . SqlServer ;
@@ -21,7 +22,6 @@ public void datetime_tests__can_use_datetime2()
21
22
22
23
using ( var conn = dbFactory . OpenDbConnection ( ) ) {
23
24
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 ( ) ;
25
25
26
26
conn . CreateTable < Table_for_datetime2_tests > ( true ) ;
27
27
@@ -38,10 +38,13 @@ public void datetime_tests__can_use_datetime2()
38
38
var fromDb2 = conn . SingleById < Table_for_datetime2_tests > ( insertedId ) ;
39
39
Assert . AreEqual ( test_object_ValidForDatetime2 . ToVerifyPrecision . Value . AddYears ( 1 ) , fromDb2 . ToVerifyPrecision ) ;
40
40
41
-
42
41
//check InsertParam
43
42
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
+ }
45
48
}
46
49
[ Test ]
47
50
public void datetime_tests__check_default_behaviour ( )
@@ -89,10 +92,10 @@ private class Table_for_datetime2_tests
89
92
public DateTime ? ToVerifyPrecision { get ; set ; }
90
93
public DateTime ? NullableDateTimeLeaveItNull { get ; set ; }
91
94
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 ) ;
96
99
97
100
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 } ; }
98
101
0 commit comments