Inheritance: System.Windows.Forms.TreeNode
 public void PopulateSubDirsOnBeforeExpand()
 {
     var node = new DirectoryNode(TargetDirectory, null);
     Assert.IsFalse(node.ThisLevelEnumerated);
     node.BeforeExpand();
     Assert.IsTrue(node.ThisLevelEnumerated);
 }
        public void SetErrorFlagPopulateSubDirs()
        {
            var node = new DirectoryNode(new DirectoryInfo(@"C:\NotGonnaFindMe"), null);
            node.PopulateSubDirs();

            Assert.IsTrue(node.HasError);
        }
Esempio n. 3
0
 public DirectoryNode(DirectoryInfo rootDir, DirectoryNode parentNode)
     : base(rootDir == null ? "" : rootDir.Name)
 {
     ThisLevelEnumerated = false;
     RootDir = rootDir;
     ParentNode = parentNode;
     Nodes.Add(new TreeNode()); // add dummy node to allow expansion
     SetImages();
 }
        public void PopulateSubDirs()
        {
            var node = new DirectoryNode(TargetDirectory, null);
            Assert.IsFalse(node.IsExpanded);

            node.PopulateSubDirs();

            var expected = TargetDirectory.GetDirectories().Select(d => new DirectoryNode(d, node));
            CollectionAssert.AreEquivalent(expected, node.SubDirs);
            Assert.IsTrue(node.ThisLevelEnumerated);
        }
        public void AllChildrenEnumeratedOnlyAfterAllSubDirsAllChildrenEnumerated()
        {
            DirectoryInfo dir = TargetDirectory.GetDirectories().First();
            MakeSubDirs(dir);
            var node = new DirectoryNode(TargetDirectory, null);
            Assert.IsFalse(node.AllChildrenEnumerated);
            node.PopulateSubDirs();
            Assert.IsFalse(node.AllChildrenEnumerated);

            foreach (var subDir in node.SubDirs)
            {
                subDir.PopulateSubDirs();
            }
            Assert.IsFalse(node.AllChildrenEnumerated);

            foreach (var subDir in node.SubDirs)
            {
                foreach (var subSubDir in subDir.SubDirs)
                {
                    subSubDir.PopulateSubDirs();
                }
            }
            Assert.IsTrue(node.AllChildrenEnumerated);
        }
Esempio n. 6
0
 private bool Equals(DirectoryNode other)
 {
     return RootDir.FullName.Equals(other.RootDir.FullName)
            && ReferenceEquals(ParentNode, other.ParentNode);
 }
 public void ThisLevelEnumeratedOnlyAfterSubDirsEnumerated()
 {
     var node = new DirectoryNode(TargetDirectory, null);
     Assert.IsFalse(node.ThisLevelEnumerated);
     node.PopulateSubDirs();
     Assert.IsTrue(node.ThisLevelEnumerated);
 }
 public void Make()
 {
     var node = new DirectoryNode(TargetDirectory, null);
     Assert.AreEqual(TargetDirectory, node.RootDir);
     Assert.AreEqual(TargetDirectory.Name, node.Text);
 }
        public void ValidateEquality()
        {
            var one = new DirectoryNode(TargetDirectory, null);
            var oneRef = one;
            var oneToo = new DirectoryNode(TargetDirectory, null);
            var two = new DirectoryNode(TargetDirectory.Parent, null);

            Assert.IsTrue(one.Equals(oneRef));
            oneRef = null;
            // ReSharper disable ExpressionIsAlwaysNull
            Assert.IsFalse(one.Equals(oneRef));
            // ReSharper restore ExpressionIsAlwaysNull
            Assert.AreEqual(one, oneToo);
            Assert.AreEqual(one.GetHashCode(), oneToo.GetHashCode());
            Assert.AreEqual(one.ToString(), oneToo.ToString());

            Assert.AreNotEqual(one, two);
            var shouldBeTrue = one == oneToo;
            Assert.IsTrue(shouldBeTrue);

            var shouldBeFalse = one != oneToo;
            Assert.IsFalse(shouldBeFalse);

            Assert.IsFalse(one.Equals(new object()));
        }
Esempio n. 10
0
 public SpyDirNode(DirectoryInfo rootDir, DirectoryNode parentNode)
     : base(rootDir, parentNode)
 {
 }