Skip to content

Commit b038fd4

Browse files
committed
Add test to ensure streams are disposed if their database is disposed.
1 parent a8f2787 commit b038fd4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

SQLitePCL.pretty.tests/ImplementationTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ public void TestRead()
602602
[Test]
603603
public void TestDispose()
604604
{
605+
Stream notDisposedStream;
606+
605607
using (var db = SQLite3.Open(":memory:"))
606608
{
607609
db.Execute("CREATE TABLE foo (x blob);");
@@ -621,7 +623,15 @@ public void TestDispose()
621623
Assert.Throws<ObjectDisposedException>(() => { blob.Read(new byte[10], 0, 2); });
622624
Assert.Throws<ObjectDisposedException>(() => { blob.Write(new byte[10], 0, 1); });
623625
Assert.Throws<ObjectDisposedException>(() => { blob.Seek(0, SeekOrigin.Begin); });
626+
627+
notDisposedStream =
628+
db.Query("SELECT rowid, x FROM foo;")
629+
.Select(row => db.OpenBlob(row[1].ColumnInfo, row[0].ToInt64(), false))
630+
.First();
624631
}
632+
633+
// Test that disposing the connection disposes the stream
634+
Assert.Throws<ObjectDisposedException>(() => { var x = notDisposedStream.Length; });
625635
}
626636

627637
[Test]

0 commit comments

Comments
 (0)