Esempio n. 1
0
 public void TestDeserializeStorableByReference()
 {
     StorableImageTest img = new StorableImageTest {
         ID = Guid.NewGuid (),
         Image1 = Utils.LoadImageFromFile (),
     };
     StorableContainerTest cont = new StorableContainerTest {
         ID = Guid.NewGuid (),
         Image = img,
     };
     storage.Store (cont);
     var cont2 = storage.Retrieve <StorableContainerTest> (cont.ID);
     Assert.IsNotNull (cont2.Image);
     Assert.AreEqual (img.ID, cont2.Image.ID);
 }
Esempio n. 2
0
 public void TestSerializeStorableByReference()
 {
     StorableImageTest img = new StorableImageTest {
         ID = Guid.NewGuid (),
         Image1 = Utils.LoadImageFromFile (),
     };
     StorableContainerTest cont = new StorableContainerTest {
         ID = Guid.NewGuid (),
         Image = img,
     };
     Document doc = db.CreateDocument ();
     UnsavedRevision rev = doc.CreateRevision ();
     JObject jo = DocumentsSerializer.SerializeObject (cont, rev, db, null);
     Assert.AreEqual (img.ID, jo ["Image"].Value<Guid> ());
     Assert.AreEqual (1, db.DocumentCount);
     Assert.IsNotNull (storage.Retrieve<StorableImageTest> (img.ID));
     rev.Save ();
     Assert.AreEqual (2, db.DocumentCount);
 }