public void TestDatabaseBackedMemoryStream() { var prepared = TestHelper.PrepareDatabaseAndBlob(this.testFile.FullName, this.random); using (var connection = new SqliteConnection(prepared.ConnectionString)) { connection.Open(); TestHelper.AssertBlobMetadata(connection, 1024, 0, 0, 0); var now = Date.Now; using (var stream = new DatabaseBackedMemoryStream(connection, UPath.Root / "test.blob", true, true)) { TestHelper.AssertBlobMetadata(connection, 1024, now, 0, 0); Assert.IsTrue(stream.CanRead); Assert.IsTrue(stream.CanSeek); Assert.IsTrue(stream.CanWrite); Assert.AreEqual(0, stream.Position); Assert.AreEqual(1024, stream.Length); var actualBlob = new byte[stream.Length]; var read = stream.Read(actualBlob, 0, 1024); Assert.AreEqual(1024, read); CollectionAssert.AreEqual(prepared.blobData, actualBlob); } // the meta data should not have been updated because no changes were made TestHelper.AssertBlobMetadata(connection, 1024, now, 0, 0); } }