public void test004_addTree() { Tree t = new Tree(db); t.Id = SOME_FAKE_ID; Assert.IsTrue(t.Id != null); Assert.IsFalse(t.IsModified); String n = "bob"; Tree f = t.AddTree(n); Assert.IsNotNull(f); Assert.AreEqual(n, f.Name); Assert.AreEqual(f.Name, Encoding.UTF8.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); }
public void test006_addDeepTree() { Tree 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 = (SOME_FAKE_ID); Assert.IsTrue(!h.IsModified); g.Id = (SOME_FAKE_ID); Assert.IsTrue(!g.IsModified); f.Id = (SOME_FAKE_ID); Assert.IsTrue(!f.IsModified); e.Id = (SOME_FAKE_ID); Assert.IsTrue(!e.IsModified); t.Id = SOME_FAKE_ID; 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); }
public void test001_createEmpty() { Tree t = new Tree(db); Assert.IsTrue(t.IsLoaded); Assert.IsTrue(t.IsModified); Assert.IsTrue(t.Parent == null); Assert.IsTrue(t.IsRoot); Assert.IsTrue(t.Name == null); Assert.IsTrue(t.NameUTF8 == null); Assert.IsTrue(t.Members != null); Assert.IsTrue(t.Members.Length == 0); Assert.AreEqual("", t.FullName); Assert.IsTrue(t.Id == null); Assert.IsTrue(t.TreeEntry == t); Assert.IsTrue(t.Repository == db); Assert.IsTrue(t.findTreeMember("foo") == null); Assert.IsTrue(t.FindBlobMember("foo") == null); }