コード例 #1
0
        public void TestCloseThenGetDatabaseName()
        {
            var name = Db.Name;

            Db.Close();
            Db.Name.Should().Be(name, "because the name of the database should still be accessible");
        }
コード例 #2
0
        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");
        }
コード例 #3
0
 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");
 }
コード例 #4
0
        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");
            }
        }
コード例 #5
0
 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");
 }
コード例 #6
0
        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");
        }
コード例 #7
0
        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");
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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");
        }
コード例 #10
0
 public void TestCloseThenGetDatabasePath()
 {
     Db.Close();
     Db.Path.Should().BeNull("because a non-open database has no path");
 }
コード例 #11
0
 public void TestCloseTwice()
 {
     Db.Close();
     Db.Close();
 }
コード例 #12
0
 public void TestClose()
 {
     Db.Close();
 }
コード例 #13
0
 public void TestClose()
 {
     Thread.Sleep(1500);
     Db.Close();
 }