@@ -216,6 +216,7 @@ type DataTablesTests() =
216216 let rowsInserted = t.Update( conn, tran)
217217 Assert.Equal( 1 , rowsInserted)
218218
219+
219220 [<Fact>]
220221 member __.SqlCommandTableUpdate () =
221222 use cmd =
@@ -229,6 +230,43 @@ type DataTablesTests() =
229230 row.ModifiedDate <- DateTime.Now.Date
230231 let rowsAffected = t.Update( conn, tran)
231232 Assert.Equal( 1 , rowsAffected)
233+
234+ [<Fact( Skip = " Don't execute for usual runs. Too slow." ) >]
235+ member __.SqlCommandTable_RespectsTimeout () =
236+ let tbl = new AdventureWorksDataTables.Production.Tables.Location()
237+
238+ use conn = new SqlConnection( connectionString = adventureWorks)
239+ conn.Open()
240+ use tran = conn.BeginTransaction()
241+
242+ tbl.AddRow( " test" , Some 12.12 M, Some 23.23 M, Some System.DateTime.UtcNow)
243+ let rowcount = tbl.Update( connection = conn, transaction = tran, timeout = TimeSpan.FromSeconds( 5.0 ))
244+
245+ let row = tbl.Rows |> Seq.head
246+
247+ row.Name <- " Slow Trigger"
248+
249+ let sw = new System.Diagnostics.Stopwatch()
250+ sw.Start()
251+
252+ let mutable completed = false
253+ try
254+ let rowcount = tbl.Update( connection = conn, transaction = tran, timeout = TimeSpan.FromSeconds( 5.0 ))
255+ completed <- true
256+ with
257+ | ex ->
258+ ()
259+
260+ sw.Stop()
261+
262+ if completed then
263+ failwith " Update should not have completed. Operation should have taken 15 seconds and timeout was set to 5 seconds."
264+ else if sw.Elapsed.TotalSeconds > 6.0 then
265+ failwith " Timeout was set to 5 seconds. Operation should have failed earlier than this"
266+ else if sw.Elapsed.TotalSeconds < 4.0 then
267+ failwith " Timeout was set to 5 seconds. Operation should have lasted longer than this. The test may be set up incorrectly"
268+
269+
232270
233271 [<Fact>]
234272 member __.NewRowAndBulkCopyWithTrsansactionScope () =
0 commit comments