/// <exception cref="System.Exception"></exception> public virtual void TestPruneRevsToMaxDepth() { IDictionary <string, object> properties = new Dictionary <string, object>(); properties.Put("testName", "testDatabaseCompaction"); properties.Put("tag", 1337); Document doc = CreateDocumentWithProperties(database, properties); SavedRevision rev = doc.GetCurrentRevision(); database.SetMaxRevTreeDepth(1); for (int i = 0; i < 10; i++) { IDictionary <string, object> properties2 = new Dictionary <string, object>(properties ); properties2.Put("tag", i); rev = rev.CreateRevision(properties2); } int numPruned = database.PruneRevsToMaxDepth(1); NUnit.Framework.Assert.AreEqual(9, numPruned); Document fetchedDoc = database.GetDocument(doc.GetId()); IList <SavedRevision> revisions = fetchedDoc.GetRevisionHistory(); NUnit.Framework.Assert.AreEqual(1, revisions.Count); numPruned = database.PruneRevsToMaxDepth(1); NUnit.Framework.Assert.AreEqual(0, numPruned); }
public void Changed(Database.ChangeEvent @event) { NUnit.Framework.Assert.AreEqual(1, @event.GetChanges().Count); DocumentChange change = @event.GetChanges()[0]; NUnit.Framework.Assert.AreEqual(DocumentId, change.GetDocumentId()); NUnit.Framework.Assert.AreEqual(rev3.GetRevId(), change.GetRevisionId()); NUnit.Framework.Assert.IsTrue(change.IsCurrentRevision()); NUnit.Framework.Assert.IsFalse(change.IsConflict()); Document doc = this._enclosing.database.GetDocument(change.GetDocumentId()); NUnit.Framework.Assert.AreEqual(rev3.GetRevId(), doc.GetCurrentRevisionId()); try { NUnit.Framework.Assert.AreEqual(3, doc.GetRevisionHistory().Count); } catch (CouchbaseLiteException ex) { Assert.Fail("CouchbaseLiteException in change listener: " + ex.ToString()); } }