public virtual void TestNonNotesWithNonNoteConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, MergeStrategy.RESOLVE); RevCommit treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt" , tr.Blob("content of a.txt")).Create(); // this is a note // this is a non-note tr.ParseBody(treeWithNonNotes); NoteMap @base = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "change 1")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap ours = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "change 2")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap theirs = NoteMap.Read(reader, treeWithNonNotes); try { merger.Merge(@base, ours, theirs); NUnit.Framework.Assert.Fail("NotesMergeConflictException was expected"); } catch (NotesMergeConflictException) { } }
public virtual void TestOursEqualsTheirs() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(empty, noRoot, noRoot) )); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a, noRoot, noRoot) )); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(noRoot, empty, empty)) ); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a, empty, empty))); result = merger.Merge(noRoot, map_a, map_a); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); result = merger.Merge(empty, map_a, map_a); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); result = merger.Merge(map_a_b, map_a, map_a); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); result = merger.Merge(map_a, map_a_b, map_a_b); NUnit.Framework.Assert.AreEqual(2, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob, result.Get(noteBId)); }
public virtual void TestFanoutAndLeafWithoutConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap largeTree = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap result = merger.Merge(map_a, map_a_b, largeTree); NUnit.Framework.Assert.AreEqual(301, CountNotes(result)); }
public virtual void TestDeleteDifferentNotes() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap map_b = NoteMap.Read(reader, sampleTree_a_b); map_b.Set(noteAId, null); // delete note a map_b.WriteTree(inserter); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a_b, map_a, map_b) )); }
public virtual void TestFanoutAndLeafWitConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree_b1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); string noteBContent1 = noteBContent + "change"; largeTree_b1.Set(noteBId, tr.Blob(noteBContent1)); largeTree_b1.WriteTree(inserter); NoteMap result = merger.Merge(map_a, map_a_b, largeTree_b1); NUnit.Framework.Assert.AreEqual(301, CountNotes(result)); NUnit.Framework.Assert.AreEqual(tr.Blob(noteBContent + noteBContent1), result.Get (noteBId)); }
public virtual void TestCollapseFanoutAfterMerge() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap largeTree = CreateLargeNoteMap("note_", "content_", 257, 0); NUnit.Framework.Assert.IsTrue(largeTree.GetRoot() is FanoutBucket); NoteMap deleteFirstHundredNotes = CreateLargeNoteMap("note_", "content_", 157, 100 ); NoteMap deleteLastHundredNotes = CreateLargeNoteMap("note_", "content_", 157, 0); NoteMap result = merger.Merge(largeTree, deleteFirstHundredNotes, deleteLastHundredNotes ); NUnit.Framework.Assert.AreEqual(57, CountNotes(result)); NUnit.Framework.Assert.IsTrue(result.GetRoot() is LeafBucket); }
public virtual void TestEditDeleteConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap result; 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_a_b1, map_a); NUnit.Framework.Assert.AreEqual(2, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob1, result.Get(noteBId)); }
public virtual void TestLargeTreesWithConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap largeTree2 = CreateLargeNoteMap("note_1_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, largeTree1, largeTree2); NUnit.Framework.Assert.AreEqual(300, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59content_2_59"), result.Get(tr .Blob("note_1_59"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_10content_2_10"), result.Get(tr .Blob("note_1_10"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_99content_2_99"), result.Get(tr .Blob("note_1_99"))); }
public virtual void TestLargeTreesWithoutConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap map1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap map2 = CreateLargeNoteMap("note_2_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, map1, map2); NUnit.Framework.Assert.AreEqual(600, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59"), result.Get(tr.Blob("note_1_59" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_10"), result.Get(tr.Blob("note_2_10" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_99"), result.Get(tr.Blob("note_2_99" ))); }
public virtual void TestAddDifferentNotes() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NoteMap map_a_c = NoteMap.Read(reader, sampleTree_a); RevBlob noteCId = tr.Blob("c"); RevBlob noteCBlob = tr.Blob("noteCContent"); map_a_c.Set(noteCId, noteCBlob); map_a_c.WriteTree(inserter); result = merger.Merge(map_a, map_a_b, map_a_c); NUnit.Framework.Assert.AreEqual(3, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob, result.Get(noteBId)); NUnit.Framework.Assert.AreEqual(noteCBlob, result.Get(noteCId)); }
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 TestNonNotesWithoutNonNoteConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, MergeStrategy.RESOLVE); RevCommit treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt" , tr.Blob("content of a.txt")).Create(); // this is a note // this is a non-note tr.ParseBody(treeWithNonNotes); NoteMap @base = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("b.txt", tr.Blob("content of b.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap ours = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("c.txt", tr.Blob("content of c.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap theirs = NoteMap.Read(reader, treeWithNonNotes); NoteMap result = merger.Merge(@base, ours, theirs); NUnit.Framework.Assert.AreEqual(3, CountNonNotes(result)); }
public virtual void TestCollapseFanoutAfterMerge() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap largeTree = CreateLargeNoteMap("note_", "content_", 257, 0); NUnit.Framework.Assert.IsTrue(largeTree.GetRoot() is FanoutBucket); NoteMap deleteFirstHundredNotes = CreateLargeNoteMap("note_", "content_", 157, 100 ); NoteMap deleteLastHundredNotes = CreateLargeNoteMap("note_", "content_", 157, 0); NoteMap result = merger.Merge(largeTree, deleteFirstHundredNotes, deleteLastHundredNotes ); NUnit.Framework.Assert.AreEqual(57, CountNotes(result)); NUnit.Framework.Assert.IsTrue(result.GetRoot() is LeafBucket); }
public virtual void TestFanoutAndLeafWitConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree_b1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); string noteBContent1 = noteBContent + "change"; largeTree_b1.Set(noteBId, tr.Blob(noteBContent1)); largeTree_b1.WriteTree(inserter); NoteMap result = merger.Merge(map_a, map_a_b, largeTree_b1); NUnit.Framework.Assert.AreEqual(301, CountNotes(result)); NUnit.Framework.Assert.AreEqual(tr.Blob(noteBContent + noteBContent1), result.Get (noteBId)); }
public virtual void TestFanoutAndLeafWithoutConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap largeTree = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap result = merger.Merge(map_a, map_a_b, largeTree); NUnit.Framework.Assert.AreEqual(301, CountNotes(result)); }
public virtual void TestLargeTreesWithConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap largeTree1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap largeTree2 = CreateLargeNoteMap("note_1_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, largeTree1, largeTree2); NUnit.Framework.Assert.AreEqual(300, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59content_2_59"), result.Get(tr .Blob("note_1_59"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_10content_2_10"), result.Get(tr .Blob("note_1_10"))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_99content_2_99"), result.Get(tr .Blob("note_1_99"))); }
public virtual void TestLargeTreesWithoutConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap map1 = CreateLargeNoteMap("note_1_", "content_1_", 300, 0); NoteMap map2 = CreateLargeNoteMap("note_2_", "content_2_", 300, 0); NoteMap result = merger.Merge(empty, map1, map2); NUnit.Framework.Assert.AreEqual(600, CountNotes(result)); // check a few random notes NUnit.Framework.Assert.AreEqual(tr.Blob("content_1_59"), result.Get(tr.Blob("note_1_59" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_10"), result.Get(tr.Blob("note_2_10" ))); NUnit.Framework.Assert.AreEqual(tr.Blob("content_2_99"), result.Get(tr.Blob("note_2_99" ))); }
public virtual void TestEditDeleteConflict() { NoteMapMerger merger = new NoteMapMerger(db, new DefaultNoteMerger(), null); NoteMap result; 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_a_b1, map_a); NUnit.Framework.Assert.AreEqual(2, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob1, result.Get(noteBId)); }
public virtual void TestDeleteDifferentNotes() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap map_b = NoteMap.Read(reader, sampleTree_a_b); map_b.Set(noteAId, null); // delete note a map_b.WriteTree(inserter); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a_b, map_a, map_b) )); }
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 TestAddDifferentNotes() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NoteMap map_a_c = NoteMap.Read(reader, sampleTree_a); RevBlob noteCId = tr.Blob("c"); RevBlob noteCBlob = tr.Blob("noteCContent"); map_a_c.Set(noteCId, noteCBlob); map_a_c.WriteTree(inserter); result = merger.Merge(map_a, map_a_b, map_a_c); NUnit.Framework.Assert.AreEqual(3, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob, result.Get(noteBId)); NUnit.Framework.Assert.AreEqual(noteCBlob, result.Get(noteCId)); }
public virtual void TestBaseEqualsTheirs() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(noRoot, empty, noRoot) )); result = merger.Merge(noRoot, map_a, noRoot); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(empty, noRoot, empty)) ); result = merger.Merge(empty, map_a, empty); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a, noRoot, map_a)) ); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(map_a, empty, map_a))); result = merger.Merge(map_a, map_a_b, map_a); NUnit.Framework.Assert.AreEqual(2, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); NUnit.Framework.Assert.AreEqual(noteBBlob, result.Get(noteBId)); }
public virtual void TestNonNotesWithoutNonNoteConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, MergeStrategy.RESOLVE); RevCommit treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt" , tr.Blob("content of a.txt")).Create(); // this is a note // this is a non-note tr.ParseBody(treeWithNonNotes); NoteMap @base = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("b.txt", tr.Blob("content of b.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap ours = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "content of a.txt")).Add("c.txt", tr.Blob("content of c.txt")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap theirs = NoteMap.Read(reader, treeWithNonNotes); NoteMap result = merger.Merge(@base, ours, theirs); NUnit.Framework.Assert.AreEqual(3, CountNonNotes(result)); }
public virtual void TestNonNotesWithNonNoteConflict() { NoteMapMerger merger = new NoteMapMerger(db, null, MergeStrategy.RESOLVE); RevCommit treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt" , tr.Blob("content of a.txt")).Create(); // this is a note // this is a non-note tr.ParseBody(treeWithNonNotes); NoteMap @base = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "change 1")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap ours = NoteMap.Read(reader, treeWithNonNotes); treeWithNonNotes = tr.Commit().Add(noteAId.Name, noteABlob).Add("a.txt", tr.Blob( "change 2")).Create(); tr.ParseBody(treeWithNonNotes); NoteMap theirs = NoteMap.Read(reader, treeWithNonNotes); try { merger.Merge(@base, ours, theirs); NUnit.Framework.Assert.Fail("NotesMergeConflictException was expected"); } catch (NotesMergeConflictException) { } }
public virtual void TestNoChange() { NoteMapMerger merger = new NoteMapMerger(db, null, null); NoteMap result; NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(noRoot, noRoot, noRoot ))); NUnit.Framework.Assert.AreEqual(0, CountNotes(merger.Merge(empty, empty, empty))); result = merger.Merge(map_a, map_a, map_a); NUnit.Framework.Assert.AreEqual(1, CountNotes(result)); NUnit.Framework.Assert.AreEqual(noteABlob, result.Get(noteAId)); }