Пример #1
0
        public void TestRetrieveStorableByReference()
        {
            StorableImageTest img = new StorableImageTest {
                ID     = Guid.NewGuid(),
                Image1 = Utils.LoadImageFromFile(),
            };
            StorableContainerTest cont = new StorableContainerTest {
                ID    = Guid.NewGuid(),
                Image = img,
            };

            storage.Store(cont);
            Assert.AreEqual(3, db.DocumentCount);
            var cont2 = storage.Retrieve <StorableContainerTest> (cont.ID);

            Assert.IsNotNull(cont2.Image);
            Assert.AreEqual(img.ID, cont2.Image.ID);
        }
Пример #2
0
        void ArrangeForRemoveDuplicates()
        {
            StorableImageTest img = new StorableImageTest {
                ID     = Guid.NewGuid(),
                Image1 = Utils.LoadImageFromFile(),
            };
            StorableContainerTest cont1 = new StorableContainerTest {
                ID    = Guid.NewGuid(),
                Image = img,
            };
            StorableContainerTest cont2 = new StorableContainerTest {
                ID    = Guid.NewGuid(),
                Image = img,
            };

            ((CouchbaseStorage)storage).AddView(typeof(StorableImageTest),
                                                new StorableImageTestView(((CouchbaseStorage)storage)));
            storage.Store(cont1);
            storage.Store(cont2);
        }
Пример #3
0
        public void TestStorableIDUsesRootStorableID()
        {
            StorableImageTest img = new StorableImageTest {
                ID     = Guid.NewGuid(),
                Image1 = Utils.LoadImageFromFile(),
            };
            StorableContainerTest cont = new StorableContainerTest {
                ID    = Guid.NewGuid(),
                Image = img,
            };

            Assert.AreEqual(0, db.DocumentCount);
            string newID = String.Format("{0}&{1}", cont.ID, img.ID);

            storage.Store(cont);
            Assert.AreEqual(3, db.DocumentCount);
            Assert.IsNotNull(db.GetExistingDocument(cont.ID.ToString()));
            Assert.IsNotNull(db.GetExistingDocument(newID));
            cont = storage.Retrieve <StorableContainerTest> (cont.ID);
            Assert.AreEqual(img.ID, cont.Image.ID);
            storage.Delete(cont);
            Assert.AreEqual(1, db.DocumentCount);
        }
Пример #4
0
        public void TestStoreStorableByReference()
        {
            StorableImageTest img = new StorableImageTest {
                ID     = Guid.NewGuid(),
                Image1 = Utils.LoadImageFromFile(),
            };
            StorableContainerTest cont = new StorableContainerTest {
                ID    = Guid.NewGuid(),
                Image = img,
            };

            Assert.AreEqual(0, db.DocumentCount);
            Document             doc     = db.CreateDocument();
            UnsavedRevision      rev     = doc.CreateRevision();
            SerializationContext context = new SerializationContext(db, cont.GetType());
            JObject jo = DocumentsSerializer.SerializeObject(cont, rev, context);

            Assert.AreEqual(img.ID.ToString(), jo ["Image"].Value <String> ());
            Assert.AreEqual(1, db.DocumentCount);
            Assert.IsNotNull(storage.Retrieve <StorableImageTest> (img.ID));
            rev.Save();
            Assert.AreEqual(2, db.DocumentCount);
        }