Exemplo n.º 1
0
        /// <exception cref="System.Exception"></exception>
        private NoteMap CreateLargeNoteMap(string noteNamePrefix, string noteContentPrefix
                                           , int notesCount, int firstIndex)
        {
            NoteMap result = NoteMap.NewEmptyMap();

            for (int i = 0; i < notesCount; i++)
            {
                result.Set(tr.Blob(noteNamePrefix + (firstIndex + i)), tr.Blob(noteContentPrefix
                                                                               + (firstIndex + i)));
            }
            result.WriteTree(inserter);
            return(result);
        }
Exemplo n.º 2
0
 public override void SetUp()
 {
     base.SetUp();
     tr           = new TestRepository <Repository>(db);
     reader       = db.NewObjectReader();
     inserter     = db.NewObjectInserter();
     noRoot       = NoteMap.NewMap(null, reader);
     empty        = NoteMap.NewEmptyMap();
     noteAId      = tr.Blob("a");
     noteAContent = "noteAContent";
     noteABlob    = tr.Blob(noteAContent);
     sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create();
     tr.ParseBody(sampleTree_a);
     map_a          = NoteMap.Read(reader, sampleTree_a);
     noteBId        = tr.Blob("b");
     noteBContent   = "noteBContent";
     noteBBlob      = tr.Blob(noteBContent);
     sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob
                                                                   ).Create();
     tr.ParseBody(sampleTree_a_b);
     map_a_b = NoteMap.Read(reader, sampleTree_a_b);
 }
        public virtual void TestCreateFromEmpty()
        {
            RevBlob a     = tr.Blob("a");
            RevBlob b     = tr.Blob("b");
            RevBlob data1 = tr.Blob("data1");
            RevBlob data2 = tr.Blob("data2");
            NoteMap map   = NoteMap.NewEmptyMap();

            NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a");
            NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b");
            map.Set(a, data1);
            map.Set(b, data2);
            NUnit.Framework.Assert.AreEqual(data1, map.Get(a));
            NUnit.Framework.Assert.AreEqual(data2, map.Get(b));
            map.Remove(a);
            map.Remove(b);
            NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a");
            NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b");
            map.Set(a, "data1", inserter);
            NUnit.Framework.Assert.AreEqual(data1, map.Get(a));
            map.Set(a, null, inserter);
            NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a");
        }
        public virtual void TestIteratorEmptyMap()
        {
            Iterator <Note> it = NoteMap.NewEmptyMap().Iterator();

            NUnit.Framework.Assert.IsFalse(it.HasNext());
        }