Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }