File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -148,8 +148,18 @@ let ``Roundtrip ToTraceString for decimals with maximum precision``() =
148148[<Fact>]
149149let ``Roundtrip ToTraceString for date time `` () =
150150 let cmd = new SqlCommandProvider< " SELECT CAST(@x AS DATETIME)" , ConnectionStrings.AdventureWorksNamed>()
151+ // SQL Server DATETIME has precision up to .00333 seconds
152+ let tolerance = 0.00334
151153 let now = System.DateTime.Now
152- let result = runScalarQuery <| cmd.ToTraceString( now)
154+ let result = runScalarQuery <| cmd.ToTraceString( now)
155+ Assert.InRange( unbox< DateTime> result, now.AddSeconds(- 1. * tolerance), now.AddSeconds( tolerance))
156+
157+ [<Fact>]
158+ let ``Roundtrip ToTraceString for datetime2 `` () =
159+ let cmd = new SqlCommandProvider< " SELECT CAST(@x AS DATETIME2)" , ConnectionStrings.AdventureWorksNamed>()
160+ // SQL Server DATETIME2 has the same nanosecond precision as DATETIMEOFFSET so there shouldn't be any discrepance
161+ let now = System.DateTime.Now
162+ let result = runScalarQuery <| cmd.ToTraceString( now)
153163 Assert.Equal( expected = now, actual = unbox< DateTime> result)
154164
155165[<Fact>]
You can’t perform that action at this time.
0 commit comments