public virtual void TestWriteUnchangedFanout2_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", string.Empty).Create();

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

            NUnit.Framework.Assert.IsTrue(map.Contains(a), "has note for a");
            NUnit.Framework.Assert.IsTrue(map.Contains(b), "has note for b");
            // This is a non-lazy map, so we'll be looking at the leaf buckets.
            RevCommit n = CommitNoteMap(map);

            NUnit.Framework.Assert.AreNotSame(r, n, "is new commit");
            NUnit.Framework.Assert.AreSame(r.Tree, n.Tree, "same tree");
            // Use a lazy-map for the next round of the same test.
            map = NoteMap.Read(reader, r);
            n   = CommitNoteMap(map);
            NUnit.Framework.Assert.AreNotSame(r, n, "is new commit");
            NUnit.Framework.Assert.AreSame(r.Tree, n.Tree, "same tree");
        }
        public virtual void TestEditFlat()
        {
            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(a.Name, data1).Add(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");
            MutableObjectId id = new MutableObjectId();

            for (int p = 42; p > 0; p--)
            {
                id.SetByte(1, p);
                map.Set(id, data1);
            }
            for (int p_1 = 42; p_1 > 0; p_1--)
            {
                id.SetByte(1, p_1);
                NUnit.Framework.Assert.IsTrue(map.Contains(id), "contains " + id);
            }
            RevCommit n = CommitNoteMap(map);

            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));
        }
        public virtual void TestReadFlatTwoNotes()
        {
            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(a.Name, data1).Add(b.Name, data2).Create();

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

            NUnit.Framework.Assert.IsNotNull(map, "have map");
            NUnit.Framework.Assert.IsTrue(map.Contains(a), "has note for a");
            NUnit.Framework.Assert.IsTrue(map.Contains(b), "has note for b");
            NUnit.Framework.Assert.AreEqual(data1, map.Get(a));
            NUnit.Framework.Assert.AreEqual(data2, map.Get(b));
            NUnit.Framework.Assert.IsFalse(map.Contains(data1), "no note for data1");
            NUnit.Framework.Assert.IsNull(map.Get(data1), "no note for data1");
        }
        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 TestWriteUnchangedFlat()
        {
            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(a.Name, data1).Add(b.Name, data2).Add(".gitignore",
                                                                                    string.Empty).Add("zoo-animals.txt", string.Empty).Create();

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

            NUnit.Framework.Assert.IsTrue(map.Contains(a), "has note for a");
            NUnit.Framework.Assert.IsTrue(map.Contains(b), "has note for b");
            RevCommit n = CommitNoteMap(map);

            NUnit.Framework.Assert.AreNotSame(r, n, "is new commit");
            NUnit.Framework.Assert.AreSame(r.Tree, n.Tree, "same tree");
        }
        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));
        }