Пример #1
0
        public void AncestryTest()
        {
            GenericFolder folder1 = new GenericFolder(_root, "folder1");
            GenericFolder folder2 = new GenericFolder(_root, "folder2");
            GenericFolder folder3 = new GenericFolder(folder2, "folder3");

            //The root folder is the ancestor of everyone
            Assert.IsTrue(_root.IsAncestorOf(folder1));
            Assert.IsTrue(_root.IsAncestorOf(folder2));
            Assert.IsTrue(_root.IsAncestorOf(folder3));

            //And everyone is the descendent of the root folder
            Assert.IsTrue(folder1.IsDescendentOf(_root));
            Assert.IsTrue(folder2.IsDescendentOf(_root));
            Assert.IsTrue(folder3.IsDescendentOf(_root));

            //Folder1 is an ancestor of neither folder2 nor folder3
            Assert.IsFalse(folder1.IsAncestorOf(_root));
            Assert.IsFalse(folder1.IsAncestorOf(folder1));
            Assert.IsFalse(folder1.IsAncestorOf(folder2));
            Assert.IsFalse(folder1.IsAncestorOf(folder3));

            //Folder2 is an ancestor of folder3
            Assert.IsFalse(folder2.IsAncestorOf(_root));
            Assert.IsFalse(folder2.IsAncestorOf(folder1));
            Assert.IsFalse(folder2.IsAncestorOf(folder2));
            Assert.IsTrue(folder2.IsAncestorOf(folder3));

            //Folder3 is an ancestor of no one
            Assert.IsFalse(folder3.IsAncestorOf(_root));
            Assert.IsFalse(folder3.IsAncestorOf(folder1));
            Assert.IsFalse(folder3.IsAncestorOf(folder2));
            Assert.IsFalse(folder3.IsAncestorOf(folder3));

            //Folder1 is a descendent of none of the folders
            Assert.IsFalse(folder1.IsDescendentOf(folder1));
            Assert.IsFalse(folder1.IsDescendentOf(folder2));
            Assert.IsFalse(folder1.IsDescendentOf(folder3));

            //Similarly folder2
            Assert.IsFalse(folder2.IsDescendentOf(folder1));
            Assert.IsFalse(folder2.IsDescendentOf(folder2));
            Assert.IsFalse(folder2.IsDescendentOf(folder3));

            //Folder3 is a descendent of folder2
            Assert.IsFalse(folder3.IsDescendentOf(folder1));
            Assert.IsTrue(folder3.IsDescendentOf(folder2));
            Assert.IsFalse(folder3.IsDescendentOf(folder3));
        }
Пример #2
0
        public void GenericEmptyTest()
        {
            GenericFolder folder = new GenericFolder(_root, "Bar");

            Assert.AreEqual(1, _root.Children.Count);
            Assert.AreEqual(0, folder.Children.Count);
            Assert.IsFalse(folder.IsAncestorOf(folder));
            Assert.IsFalse(folder.IsDescendentOf(folder));
            Assert.AreEqual("Bar", folder.Name);
            Assert.AreEqual(_root.Path + folder.Name, folder.Path);
            Assert.AreEqual(_root, folder.Parent);
            Assert.AreEqual(_root, folder.ParentFolder);
            Assert.AreEqual(_root, folder.FileSystemParent);
            Assert.AreEqual(_root, folder.RootFolder);
        }
Пример #3
0
        public void NullIsAncestorTest()
        {
            GenericFolder folder = new GenericFolder(_root, "Bar");

            //Can't pass null to IsAncestorOf
            folder.IsAncestorOf(null);
        }