Пример #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");
        }
 /// <exception cref="System.IO.IOException"></exception>
 internal virtual void ReadTree(string prefix, Tree t)
 {
     TreeEntry[] members = t.Members();
     for (int i = 0; i < members.Length; ++i)
     {
         TreeEntry te = members[i];
         string    name;
         if (prefix.Length > 0)
         {
             name = prefix + "/" + te.GetName();
         }
         else
         {
             name = te.GetName();
         }
         if (te is Tree)
         {
             ReadTree(name, (Tree)te);
         }
         else
         {
             GitIndex.Entry e = new GitIndex.Entry(this, te, 0);
             entries.Put(Constants.Encode(name), e);
         }
     }
 }
Пример #3
0
        public virtual void Test007_manyFileLookup()
        {
            Tree t = new Tree(db);
            IList <FileTreeEntry> files = new AList <FileTreeEntry>(26 * 26);

            for (char level1 = 'a'; level1 <= 'z'; level1++)
            {
                for (char level2 = 'a'; level2 <= 'z'; level2++)
                {
                    string        n = "." + level1 + level2 + "9";
                    FileTreeEntry f = t.AddFile(n);
                    NUnit.Framework.Assert.IsNotNull(f, "File " + n + " added.");
                    NUnit.Framework.Assert.AreEqual(n, f.GetName());
                    files.AddItem(f);
                }
            }
            NUnit.Framework.Assert.AreEqual(files.Count, t.MemberCount());
            TreeEntry[] ents = t.Members();
            NUnit.Framework.Assert.IsNotNull(ents);
            NUnit.Framework.Assert.AreEqual(files.Count, ents.Length);
            for (int k = 0; k < ents.Length; k++)
            {
                NUnit.Framework.Assert.IsTrue(files[k] == ents[k], "File " + files[k].GetName() +
                                              " is at " + k + ".");
            }
        }
Пример #4
0
        public virtual void Test002_addFile()
        {
            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";
            FileTreeEntry f = t.AddFile(n);

            NUnit.Framework.Assert.IsNotNull(f, "have file");
            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(t.IsModified(), "is modified");
            NUnit.Framework.Assert.IsTrue(t.GetId() == null, "has no id");
            NUnit.Framework.Assert.IsTrue(t.FindBlobMember(f.GetName()) == f, "found bob");
            TreeEntry[] i = t.Members();
            NUnit.Framework.Assert.IsNotNull(i, "members array not null");
            NUnit.Framework.Assert.IsTrue(i != null && i.Length > 0, "iterator is not empty");
            NUnit.Framework.Assert.IsTrue(i != null && i[0] == f, "iterator returns file");
            NUnit.Framework.Assert.IsTrue(i != null && i.Length == 1, "iterator is empty");
        }
Пример #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");
        }
Пример #6
0
        public virtual void Test008_SubtreeInternalSorting()
        {
            Tree          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();
            NUnit.Framework.Assert.AreSame(e1, ents[0]);
            NUnit.Framework.Assert.AreSame(e0, ents[1]);
            NUnit.Framework.Assert.AreSame(e3, ents[2]);
            NUnit.Framework.Assert.AreSame(e4, ents[3]);
            NUnit.Framework.Assert.AreSame(e2, ents[4]);
        }
Пример #7
0
		public virtual void Test008_SubtreeInternalSorting()
		{
			Tree 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();
			NUnit.Framework.Assert.AreSame(e1, ents[0]);
			NUnit.Framework.Assert.AreSame(e0, ents[1]);
			NUnit.Framework.Assert.AreSame(e3, ents[2]);
			NUnit.Framework.Assert.AreSame(e4, ents[3]);
			NUnit.Framework.Assert.AreSame(e2, ents[4]);
		}
Пример #8
0
		public virtual void Test007_manyFileLookup()
		{
			Tree t = new Tree(db);
			IList<FileTreeEntry> files = new AList<FileTreeEntry>(26 * 26);
			for (char level1 = 'a'; level1 <= 'z'; level1++)
			{
				for (char level2 = 'a'; level2 <= 'z'; level2++)
				{
					string n = "." + level1 + level2 + "9";
					FileTreeEntry f = t.AddFile(n);
					NUnit.Framework.Assert.IsNotNull(f, "File " + n + " added.");
					NUnit.Framework.Assert.AreEqual(n, f.GetName());
					files.AddItem(f);
				}
			}
			NUnit.Framework.Assert.AreEqual(files.Count, t.MemberCount());
			TreeEntry[] ents = t.Members();
			NUnit.Framework.Assert.IsNotNull(ents);
			NUnit.Framework.Assert.AreEqual(files.Count, ents.Length);
			for (int k = 0; k < ents.Length; k++)
			{
				NUnit.Framework.Assert.IsTrue(files[k] == ents[k], "File " + files[k].GetName() +
					 " is at " + k + ".");
			}
		}
Пример #9
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");
		}
Пример #10
0
		public virtual void Test002_addFile()
		{
			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";
			FileTreeEntry f = t.AddFile(n);
			NUnit.Framework.Assert.IsNotNull(f, "have file");
			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(t.IsModified(), "is modified");
			NUnit.Framework.Assert.IsTrue(t.GetId() == null, "has no id");
			NUnit.Framework.Assert.IsTrue(t.FindBlobMember(f.GetName()) == f, "found bob");
			TreeEntry[] i = t.Members();
			NUnit.Framework.Assert.IsNotNull(i, "members array not null");
			NUnit.Framework.Assert.IsTrue(i != null && i.Length > 0, "iterator is not empty");
			NUnit.Framework.Assert.IsTrue(i != null && i[0] == f, "iterator returns file");
			NUnit.Framework.Assert.IsTrue(i != null && i.Length == 1, "iterator is empty");
		}
Пример #11
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");
		}