当前位置: 首页>>代码示例>>C#>>正文


C# Tree.AddTree方法代码示例

本文整理汇总了C#中Tree.AddTree方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.AddTree方法的具体用法?C# Tree.AddTree怎么用?C# Tree.AddTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.AddTree方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testMissingSubtree_DetectFileAdded_FileModified

        public void testMissingSubtree_DetectFileAdded_FileModified()
        {
            var ow = new ObjectWriter(db);
            ObjectId aFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("a"));
            ObjectId bFileId = ow.WriteBlob(Constants.CHARSET.GetBytes("b"));
            ObjectId cFileId1 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-1"));
            ObjectId cFileId2 = ow.WriteBlob(Constants.CHARSET.GetBytes("c-2"));

            // Create sub-a/empty, sub-c/empty = hello.
            Func<ObjectId> oldTree = () =>
                                     	{
                                     		var root = new Tree(db);

                                     		Tree subA = root.AddTree("sub-a");
                                     		subA.AddFile("empty").Id = aFileId;
                                     		subA.Id = ow.WriteTree(subA);

                                     		Tree subC = root.AddTree("sub-c");
                                     		subC.AddFile("empty").Id = cFileId1;
                                     		subC.Id = ow.WriteTree(subC);

                                     		return ow.WriteTree(root);
                                     	};

            // Create sub-a/empty, sub-b/empty, sub-c/empty.
            Func<ObjectId> newTree = () =>
                                     	{
                                     		var root = new Tree(db);

                                     		Tree subA = root.AddTree("sub-a");
                                     		subA.AddFile("empty").Id = aFileId;
                                     		subA.Id = ow.WriteTree(subA);

                                     		Tree subB = root.AddTree("sub-b");
                                     		subB.AddFile("empty").Id = bFileId;
                                     		subB.Id = ow.WriteTree(subB);

                                     		Tree subC = root.AddTree("sub-c");
                                     		subC.AddFile("empty").Id = cFileId2;
                                     		subC.Id = ow.WriteTree(subC);

                                     		return ow.WriteTree(root);
                                     	};

            var tw = new GitSharp.TreeWalk.TreeWalk(db);
            tw.reset(new[] { oldTree.Invoke(), newTree.Invoke() });
            tw.Recursive = true;
            tw.setFilter(TreeFilter.ANY_DIFF);

            Assert.IsTrue(tw.next());
            Assert.AreEqual("sub-b/empty", tw.getPathString());
            Assert.AreEqual(FileMode.Missing, tw.getFileMode(0));
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
            Assert.AreEqual(ObjectId.ZeroId, tw.getObjectId(0));
            Assert.AreEqual(bFileId, tw.getObjectId(1));

            Assert.IsTrue(tw.next());
            Assert.AreEqual("sub-c/empty", tw.getPathString());
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(0));
            Assert.AreEqual(FileMode.RegularFile, tw.getFileMode(1));
            Assert.AreEqual(cFileId1, tw.getObjectId(0));
            Assert.AreEqual(cFileId2, tw.getObjectId(1));

            Assert.IsFalse(tw.next());
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:65,代码来源:TreeWalkBasicDiffTest.cs

示例2: testSimpleT

 public void testSimpleT()
 {
     Tree tree = new Tree(db);
     tree.AddTree("a");
     TreeIterator i = MakeIterator(tree);
     Assert.IsTrue(i.hasNext());
     Assert.AreEqual("", i.next().FullName);
     Assert.IsTrue(i.hasNext());
     Assert.AreEqual("a", i.next().FullName);
     Assert.IsFalse(i.hasNext());
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:11,代码来源:TreeIteratorPreOrderTest.cs

示例3: test008_SubtreeInternalSorting

        public void test008_SubtreeInternalSorting()
        {
            var t = new Tree(db);
            FileTreeEntry e0 = t.AddFile("a-b");
            FileTreeEntry e1 = t.AddFile("a-");
            FileTreeEntry e2 = t.AddFile("a=b");
            Tree e3 = t.AddTree("a");
            FileTreeEntry e4 = t.AddFile("a=");

            TreeEntry[] ents = t.Members;
            Assert.AreSame(e1, ents[0]);
            Assert.AreSame(e0, ents[1]);
            Assert.AreSame(e3, ents[2]);
            Assert.AreSame(e4, ents[3]);
            Assert.AreSame(e2, ents[4]);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:16,代码来源:TreeTests.cs

示例4: test006_addDeepTree

        public void test006_addDeepTree()
        {
            var t = new Tree(db);

            Tree e = t.AddTree("e");
            Assert.IsNotNull(e);
            Assert.IsTrue(e.Parent == t);
            Tree f = t.AddTree("f");
            Assert.IsNotNull(f);
            Assert.IsTrue(f.Parent == t);
            Tree g = f.AddTree("g");
            Assert.IsNotNull(g);
            Assert.IsTrue(g.Parent == f);
            Tree h = g.AddTree("h");
            Assert.IsNotNull(h);
            Assert.IsTrue(h.Parent == g);

            h.Id = SomeFakeId;
            Assert.IsTrue(!h.IsModified);
            g.Id = SomeFakeId;
            Assert.IsTrue(!g.IsModified);
            f.Id = SomeFakeId;
            Assert.IsTrue(!f.IsModified);
            e.Id = SomeFakeId;
            Assert.IsTrue(!e.IsModified);
            t.Id = SomeFakeId;
            Assert.IsTrue(!t.IsModified);

            Assert.AreEqual("f/g/h", h.FullName);
            Assert.IsTrue(t.findTreeMember(h.FullName) == h);
            Assert.IsTrue(t.FindBlobMember("f/z") == null);
            Assert.IsTrue(t.FindBlobMember("y/z") == null);

            FileTreeEntry i = h.AddFile("i");
            Assert.IsNotNull(i);
            Assert.AreEqual("f/g/h/i", i.FullName);
            Assert.IsTrue(t.FindBlobMember(i.FullName) == i);
            Assert.IsTrue(h.IsModified);
            Assert.IsTrue(g.IsModified);
            Assert.IsTrue(f.IsModified);
            Assert.IsTrue(!e.IsModified);
            Assert.IsTrue(t.IsModified);

            Assert.IsTrue(h.Id == null);
            Assert.IsTrue(g.Id == null);
            Assert.IsTrue(f.Id == null);
            Assert.IsTrue(e.Id != null);
            Assert.IsTrue(t.Id == null);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:49,代码来源:TreeTests.cs

示例5: test005_addRecursiveTree

 public void test005_addRecursiveTree()
 {
     var t = new Tree(db);
     Tree f = t.AddTree("a/b/c");
     Assert.IsNotNull(f);
     Assert.AreEqual(f.Name, "c");
     Assert.AreEqual(f.Parent.Name, "b");
     Assert.AreEqual(f.Parent.Parent.Name, "a");
     Assert.IsTrue(t == f.Parent.Parent.Parent, "t is great-grandparent");
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:10,代码来源:TreeTests.cs

示例6: test004_addTree

        public void test004_addTree()
        {
            var t = new Tree(db) {Id = SomeFakeId};
            Assert.IsTrue(t.Id != null);
            Assert.IsFalse(t.IsModified);

            const string n = "bob";
            Tree f = t.AddTree(n);
            Assert.IsNotNull(f);
            Assert.AreEqual(n, f.Name);
            Assert.AreEqual(f.Name, Constants.CHARSET.GetString(f.NameUTF8));
            Assert.AreEqual(n, f.FullName);
            Assert.IsTrue(f.Id == null);
            Assert.IsTrue(f.Parent == t);
            Assert.IsTrue(f.Repository == db);
            Assert.IsTrue(f.IsLoaded);
            Assert.IsFalse(f.Members.Length > 0);
            Assert.IsFalse(f.IsRoot);
            Assert.IsTrue(f.TreeEntry == f);
            Assert.IsTrue(t.IsModified);
            Assert.IsTrue(t.Id == null);
            Assert.IsTrue(t.findTreeMember(f.Name) == f);

            TreeEntry[] i = t.Members;
            Assert.IsTrue(i.Length > 0);
            Assert.IsTrue(i[0] == f);
            Assert.IsTrue(i.Length == 1);
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:28,代码来源:TreeTests.cs

示例7: testSimpleT

 public void testSimpleT()
 {
     Tree tree = new Tree(db);
     tree.AddTree("a");
     TreeIterator i = MakeIterator(tree);
     Assert.IsFalse(i.hasNext());
 }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:7,代码来源:TreeIteratorLeafOnlyTest.cs


注:本文中的Tree.AddTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。