Exemplo n.º 1
0
        public virtual void Test004_addTree()
        {
            Tree t = new Tree(db);

            t.SetId(SOME_FAKE_ID);
            NUnit.Framework.Assert.IsTrue(t.GetId() != null, "has id");
            NUnit.Framework.Assert.IsFalse(t.IsModified(), "not modified");
            string n = "bob";
            Tree   f = t.AddTree(n);

            NUnit.Framework.Assert.IsNotNull(f, "have tree");
            NUnit.Framework.Assert.AreEqual(n, f.GetName(), "name matches");
            NUnit.Framework.Assert.AreEqual(f.GetName(), Sharpen.Runtime.GetStringForBytes(f.
                                                                                           GetNameUTF8(), "UTF-8"), "name matches");
            NUnit.Framework.Assert.AreEqual(n, f.GetFullName(), "full name matches");
            NUnit.Framework.Assert.IsTrue(f.GetId() == null, "no id");
            NUnit.Framework.Assert.IsTrue(f.GetParent() == t, "parent matches");
            NUnit.Framework.Assert.IsTrue(f.GetRepository() == db, "repository matches");
            NUnit.Framework.Assert.IsTrue(f.IsLoaded(), "isLoaded");
            NUnit.Framework.Assert.IsFalse(f.Members().Length > 0, "has items");
            NUnit.Framework.Assert.IsFalse(f.IsRoot(), "is root");
            NUnit.Framework.Assert.IsTrue(t.IsModified(), "parent is modified");
            NUnit.Framework.Assert.IsTrue(t.GetId() == null, "parent has no id");
            NUnit.Framework.Assert.IsTrue(t.FindTreeMember(f.GetName()) == f, "found bob child"
                                          );
            TreeEntry[] i = t.Members();
            NUnit.Framework.Assert.IsTrue(i.Length > 0, "iterator is not empty");
            NUnit.Framework.Assert.IsTrue(i[0] == f, "iterator returns file");
            NUnit.Framework.Assert.AreEqual(1, i.Length, "iterator is empty");
        }
Exemplo n.º 2
0
        public virtual void Test001_createEmpty()
        {
            Tree t = new Tree(db);

            NUnit.Framework.Assert.IsTrue(t.IsLoaded(), "isLoaded");
            NUnit.Framework.Assert.IsTrue(t.IsModified(), "isModified");
            NUnit.Framework.Assert.IsTrue(t.GetParent() == null, "no parent");
            NUnit.Framework.Assert.IsTrue(t.IsRoot(), "isRoot");
            NUnit.Framework.Assert.IsTrue(t.GetName() == null, "no name");
            NUnit.Framework.Assert.IsTrue(t.GetNameUTF8() == null, "no nameUTF8");
            NUnit.Framework.Assert.IsTrue(t.Members() != null, "has entries array");
            NUnit.Framework.Assert.AreEqual(0, t.Members().Length, "entries is empty");
            NUnit.Framework.Assert.AreEqual(string.Empty, t.GetFullName(), "full name is empty"
                                            );
            NUnit.Framework.Assert.IsTrue(t.GetId() == null, "no id");
            NUnit.Framework.Assert.IsTrue(t.GetRepository() == db, "database is r");
            NUnit.Framework.Assert.IsTrue(t.FindTreeMember("foo") == null, "no foo child");
            NUnit.Framework.Assert.IsTrue(t.FindBlobMember("foo") == null, "no foo child");
        }
Exemplo n.º 3
0
 /// <summary>Construct a new Tree under another Tree</summary>
 /// <param name="parent"></param>
 /// <param name="nameUTF8"></param>
 public Tree(NGit.Tree parent, byte[] nameUTF8) : base(parent, null, nameUTF8)
 {
     db       = parent.GetRepository();
     contents = EMPTY_TREE;
 }
Exemplo n.º 4
0
 /// <summary>Construct a Tree with a known SHA-1 under another tree.</summary>
 /// <remarks>
 /// Construct a Tree with a known SHA-1 under another tree. Data is not yet
 /// specified and will have to be loaded on demand.
 /// </remarks>
 /// <param name="parent"></param>
 /// <param name="id"></param>
 /// <param name="nameUTF8"></param>
 protected internal Tree(NGit.Tree parent, ObjectId id, byte[] nameUTF8) : base(parent
                                                                                , id, nameUTF8)
 {
     db = parent.GetRepository();
 }
Exemplo n.º 5
0
		public virtual void Test001_createEmpty()
		{
			Tree t = new Tree(db);
			NUnit.Framework.Assert.IsTrue(t.IsLoaded(), "isLoaded");
			NUnit.Framework.Assert.IsTrue(t.IsModified(), "isModified");
			NUnit.Framework.Assert.IsTrue(t.GetParent() == null, "no parent");
			NUnit.Framework.Assert.IsTrue(t.IsRoot(), "isRoot");
			NUnit.Framework.Assert.IsTrue(t.GetName() == null, "no name");
			NUnit.Framework.Assert.IsTrue(t.GetNameUTF8() == null, "no nameUTF8");
			NUnit.Framework.Assert.IsTrue(t.Members() != null, "has entries array");
			NUnit.Framework.Assert.AreEqual(0, t.Members().Length, "entries is empty");
			NUnit.Framework.Assert.AreEqual(string.Empty, t.GetFullName(), "full name is empty"
				);
			NUnit.Framework.Assert.IsTrue(t.GetId() == null, "no id");
			NUnit.Framework.Assert.IsTrue(t.GetRepository() == db, "database is r");
			NUnit.Framework.Assert.IsTrue(t.FindTreeMember("foo") == null, "no foo child");
			NUnit.Framework.Assert.IsTrue(t.FindBlobMember("foo") == null, "no foo child");
		}