Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
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 + ".");
            }
        }
Ejemplo n.º 3
0
        public virtual void Test005_addRecursiveFile()
        {
            Tree          t = new Tree(db);
            FileTreeEntry f = t.AddFile("a/b/c");

            NUnit.Framework.Assert.IsNotNull(f, "created f");
            NUnit.Framework.Assert.AreEqual("c", f.GetName());
            NUnit.Framework.Assert.AreEqual("b", f.GetParent().GetName());
            NUnit.Framework.Assert.AreEqual("a", f.GetParent().GetParent().GetName());
            NUnit.Framework.Assert.IsTrue(t == f.GetParent().GetParent().GetParent(), "t is great-grandparent"
                                          );
        }
Ejemplo n.º 4
0
		/// <exception cref="System.IO.IOException"></exception>
		public override void VisitFile(FileTreeEntry f)
		{
			FilePath path = new FilePath(GetCurrentDirectory(), f.GetName());
			FileInputStream @in = new FileInputStream(path);
			try
			{
				long sz = @in.GetChannel().Size();
				f.SetId(inserter.Insert(Constants.OBJ_BLOB, sz, @in));
				inserter.Flush();
			}
			finally
			{
				inserter.Release();
				@in.Close();
			}
		}