Beispiel #1
0
        public virtual void TestEditDifferentNotes()
        {
            NoteMapMerger merger = new NoteMapMerger(db, null, null);
            NoteMap       result;
            NoteMap       map_a1_b      = NoteMap.Read(reader, sampleTree_a_b);
            string        noteAContent1 = noteAContent + "change";
            RevBlob       noteABlob1    = tr.Blob(noteAContent1);

            map_a1_b.Set(noteAId, noteABlob1);
            map_a1_b.WriteTree(inserter);
            NoteMap map_a_b1      = NoteMap.Read(reader, sampleTree_a_b);
            string  noteBContent1 = noteBContent + "change";
            RevBlob noteBBlob1    = tr.Blob(noteBContent1);

            map_a_b1.Set(noteBId, noteBBlob1);
            map_a_b1.WriteTree(inserter);
            result = merger.Merge(map_a_b, map_a1_b, map_a_b1);
            NUnit.Framework.Assert.AreEqual(2, CountNotes(result));
            NUnit.Framework.Assert.AreEqual(noteABlob1, result.Get(noteAId));
            NUnit.Framework.Assert.AreEqual(noteBBlob1, result.Get(noteBId));
        }
Beispiel #2
0
        public virtual void TestEditSameNoteDifferentContent()
        {
            NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null);
            NoteMap       result;
            NoteMap       map_a1        = NoteMap.Read(reader, sampleTree_a);
            string        noteAContent1 = noteAContent + "change1";
            RevBlob       noteABlob1    = tr.Blob(noteAContent1);

            map_a1.Set(noteAId, noteABlob1);
            map_a1.WriteTree(inserter);
            NoteMap map_a2        = NoteMap.Read(reader, sampleTree_a);
            string  noteAContent2 = noteAContent + "change2";
            RevBlob noteABlob2    = tr.Blob(noteAContent2);

            map_a2.Set(noteAId, noteABlob2);
            map_a2.WriteTree(inserter);
            result = merger.Merge(map_a, map_a1, map_a2);
            NUnit.Framework.Assert.AreEqual(1, CountNotes(result));
            NUnit.Framework.Assert.AreEqual(tr.Blob(noteAContent1 + noteAContent2), result.Get
                                                (noteAId));
        }
        public virtual void TestEditFanout2_38()
        {
            RevBlob   a     = tr.Blob("a");
            RevBlob   b     = tr.Blob("b");
            RevBlob   data1 = tr.Blob("data1");
            RevBlob   data2 = tr.Blob("data2");
            RevCommit r     = tr.Commit().Add(Fanout(2, a.Name), data1).Add(Fanout(2, b.Name), data2
                                                                            ).Add(".gitignore", string.Empty).Add("zoo-animals.txt", b).Create();

            //
            //
            //
            //
            //
            tr.ParseBody(r);
            NoteMap map = NoteMap.Read(reader, r);

            map.Set(a, data2);
            map.Set(b, null);
            map.Set(data1, b);
            map.Set(data2, null);
            NUnit.Framework.Assert.AreEqual(data2, map.Get(a));
            NUnit.Framework.Assert.AreEqual(b, map.Get(data1));
            NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b");
            NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2");
            RevCommit n = CommitNoteMap(map);

            map.Set(a, null);
            map.Set(data1, null);
            NUnit.Framework.Assert.IsFalse(map.Contains(a), "no a");
            NUnit.Framework.Assert.IsFalse(map.Contains(data1), "no data1");
            map = NoteMap.Read(reader, n);
            NUnit.Framework.Assert.AreEqual(data2, map.Get(a));
            NUnit.Framework.Assert.AreEqual(b, map.Get(data1));
            NUnit.Framework.Assert.IsFalse(map.Contains(b), "no b");
            NUnit.Framework.Assert.IsFalse(map.Contains(data2), "no data2");
            NUnit.Framework.Assert.AreEqual(b, TreeWalk.ForPath(reader, "zoo-animals.txt", n.
                                                                Tree).GetObjectId(0));
        }