public static Document CreateDocumentWithProperties(Database db, IDictionary <string , object> properties) { Document doc = db.CreateDocument(); NUnit.Framework.Assert.IsNotNull(doc); NUnit.Framework.Assert.IsNull(doc.GetCurrentRevisionId()); NUnit.Framework.Assert.IsNull(doc.GetCurrentRevision()); NUnit.Framework.Assert.IsNotNull("Document has no ID", doc.GetId()); // 'untitled' docs are no longer untitled (8/10/12) try { doc.PutProperties(properties); } catch (Exception e) { Log.E(Tag, "Error creating document", e); NUnit.Framework.Assert.IsTrue("can't create new document in db:" + db.GetName() + " with properties:" + properties.ToString(), false); } NUnit.Framework.Assert.IsNotNull(doc.GetId()); NUnit.Framework.Assert.IsNotNull(doc.GetCurrentRevisionId()); NUnit.Framework.Assert.IsNotNull(doc.GetUserProperties()); // this won't work until the weakref hashmap is implemented which stores all docs // Assert.assertEquals(db.getDocument(doc.getId()), doc); NUnit.Framework.Assert.AreEqual(db.GetDocument(doc.GetId()).GetId(), doc.GetId()); return(doc); }
public static Document CreateDocumentWithProperties(Database db, IDictionary <string , object> properties) { Document doc = db.CreateDocument(); NUnit.Framework.Assert.IsNotNull(doc); NUnit.Framework.Assert.IsNull(doc.GetCurrentRevisionId()); NUnit.Framework.Assert.IsNull(doc.GetCurrentRevision()); NUnit.Framework.Assert.IsNotNull("Document has no ID", doc.GetId()); // 'untitled' docs are no longer untitled (8/10/12) try { doc.PutProperties(properties); } catch (Exception e) { Log.E(Tag, "Error creating document", e); NUnit.Framework.Assert.IsTrue("can't create new document in db:" + db.GetName() + " with properties:" + properties.ToString(), false); } NUnit.Framework.Assert.IsNotNull(doc.GetId()); NUnit.Framework.Assert.IsNotNull(doc.GetCurrentRevisionId()); NUnit.Framework.Assert.IsNotNull(doc.GetUserProperties()); // should be same doc instance, since there should only ever be a single Document instance for a given document NUnit.Framework.Assert.AreEqual(db.GetDocument(doc.GetId()), doc); NUnit.Framework.Assert.AreEqual(db.GetDocument(doc.GetId()).GetId(), doc.GetId()); return(doc); }
/// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception> public virtual void TestServer() { //to ensure this test is easily repeatable we will explicitly remove //any stale foo.cblite bool mustExist = true; Database old = manager.GetDatabaseWithoutOpening("foo", mustExist); if (old != null) { old.Delete(); } mustExist = false; Database db = manager.GetDatabaseWithoutOpening("foo", mustExist); NUnit.Framework.Assert.IsNotNull(db); NUnit.Framework.Assert.AreEqual("foo", db.GetName()); NUnit.Framework.Assert.IsTrue(db.GetPath().StartsWith(GetServerPath())); NUnit.Framework.Assert.IsFalse(db.Exists()); // because foo doesn't exist yet IList <string> databaseNames = manager.GetAllDatabaseNames(); NUnit.Framework.Assert.IsTrue(!databaseNames.Contains("foo")); NUnit.Framework.Assert.IsTrue(db.Open()); NUnit.Framework.Assert.IsTrue(db.Exists()); databaseNames = manager.GetAllDatabaseNames(); NUnit.Framework.Assert.IsTrue(databaseNames.Contains("foo")); db.Close(); db.Delete(); }
internal void ForgetDatabase(Database db) { // remove from cached list of dbs Sharpen.Collections.Remove(databases, db.GetName()); // remove from list of replications // TODO: should there be something that actually stops the replication(s) first? IEnumerator <Replication> replicationIterator = this.replications.GetEnumerator(); while (replicationIterator.HasNext()) { Replication replication = replicationIterator.Next(); if (replication.GetLocalDatabase().GetName().Equals(db.GetName())) { replicationIterator.Remove(); } } }
internal void ForgetDatabase(Database db) { // remove from cached list of dbs Sharpen.Collections.Remove(databases, db.GetName()); // remove from list of replications // TODO: should there be something that actually stops the replication(s) first? IEnumerator<Replication> replicationIterator = this.replications.GetEnumerator(); while (replicationIterator.HasNext()) { Replication replication = replicationIterator.Next(); if (replication.GetLocalDatabase().GetName().Equals(db.GetName())) { replicationIterator.Remove(); } } }