public void TestCloseThenGetDatabaseName() { var name = Db.Name; Db.Close(); Db.Name.Should().Be(name, "because the name of the database should still be accessible"); }
public void TestPurgeDocOnClosedDB() { var doc = GenerateDocument("doc1"); Db.Close(); Db.Invoking(d => d.Purge(doc)) .ShouldThrow <InvalidOperationException>() .WithMessage("Attempt to perform an operation on a closed database", "because this operation is invalid"); }
public void TestCloseThenCallInBatch() { Db.Invoking(d => d.InBatch(() => { Db.Close(); })) .ShouldThrow <CouchbaseLiteException>() .Where( e => e.Error == CouchbaseLiteError.TransactionNotClosed && e.Domain == CouchbaseLiteErrorType.CouchbaseLite, "because a database can't be closed in the middle of a batch"); }
public void TestGetDocFromClosedDB() { using (var doc = GenerateDocument("doc1")) { Db.Close(); Db.Invoking(d => d.GetDocument("doc1")) .Should().Throw <InvalidOperationException>() .WithMessage("Attempt to perform an operation on a closed database.", "because this operation is invalid"); } }
public void TestCloseThenCallInBatch() { Db.Invoking(d => d.InBatch(() => { Db.Close(); })) .ShouldThrow <LiteCoreException>() .Which.Error.Should() .Match <C4Error>( e => e.code == (int)C4ErrorCode.TransactionNotClosed && e.domain == C4ErrorDomain.LiteCoreDomain, "because a database can't be closed in the middle of a batch"); }
public void TestCloseThenAccessBlob() { var doc = GenerateDocument("doc1").ToMutable(); var savedDoc = StoreBlob(Db, doc, Encoding.UTF8.GetBytes("12345")); Db.Close(); var blob = savedDoc.GetBlob("data"); blob.Should().NotBeNull("because the blob should still exist and be accessible"); blob.Length.Should().Be(5, "because the blob's metadata should still be accessible"); blob.Content.Should().BeNull("because the content cannot be read from a closed database"); }
public void TestSaveDocToClosedDB() { Db.Close(); var doc = new MutableDocument("doc1"); doc.SetInt("key", 1); Db.Invoking(d => d.Save(doc)) .ShouldThrow <InvalidOperationException>() .WithMessage("Attempt to perform an operation on a closed database", "because this operation is invalid"); }
public void TestConcurrentCreateAndCloseDB() { const int nDocs = 1000; var exp1 = new WaitAssert(); var ignore = exp1.RunAssertAsync(() => { Action a = () => CreateDocs(nDocs, "Create").ToList(); a.Should().Throw <InvalidOperationException>(); }); Db.Close(); exp1.WaitForResult(TimeSpan.FromSeconds(60)); }
public void TestCloseThenAccessDoc() { var docID = "doc1"; var doc = GenerateDocument(docID); Db.Close(); doc.Id.Should().Be(docID, "because a document's ID should never change"); doc.GetInt("key").Should().Be(1, "because the document's data should still be accessible"); // Modification should still succeed var updatedDoc = doc.ToMutable(); updatedDoc.SetInt("key", 2); updatedDoc.SetString("key1", "value"); }
public void TestCloseThenGetDatabasePath() { Db.Close(); Db.Path.Should().BeNull("because a non-open database has no path"); }
public void TestCloseTwice() { Db.Close(); Db.Close(); }
public void TestClose() { Db.Close(); }
public void TestClose() { Thread.Sleep(1500); Db.Close(); }