Skip to content

Commit 8d201f9

Browse files
Add unit test checking proper disposal of connection when expected
1 parent 1c6da94 commit 8d201f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/SqlClient.Tests/CreateCommand.fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,17 @@ let CreareDynamicRecords() =
173173
|> Seq.toArray
174174
|> ignore
175175

176+
177+
[<Fact>]
178+
let ``connection is properly disposed`` () =
179+
180+
let mutable connection : SqlConnection = null
181+
let mutable isDisposed = false
182+
do
183+
use cmd = DB.CreateCommand<"exec dbo.[Get]", ResultType.DataReader>()
184+
connection <- (cmd :> ISqlCommand).Raw.Connection
185+
connection.Disposed.Add(fun _ -> isDisposed <- true)
186+
use reader = cmd.Execute()
187+
()
188+
189+
Assert.True isDisposed

0 commit comments

Comments
 (0)