Exemplo n.º 1
0
        public void GetNodeByPath_SingleLevelPath_ReturnsCorrespondingNode()
        {
            // Arrange
            var nodeWalker    = new NodeWalker();
            var rootDirectory = new Directory {
                Name = "Root"
            };
            var childDirectory = new Directory {
                Name = "A"
            };

            rootDirectory.AddChild(childDirectory);

            // Act
            var result = nodeWalker.GetNodeByPath(rootDirectory, "A");

            // Assert
            Assert.AreEqual(childDirectory, result);
        }
Exemplo n.º 2
0
        public void GetNodeByPath_NullPath_ReturnsRoot()
        {
            // Arrange
            var nodeWalker    = new NodeWalker();
            var rootDirectory = new Directory()
            {
                Name = "Root"
            };
            var childDirectory = new Directory {
                Name = "A"
            };

            rootDirectory.AddChild(childDirectory);

            // Act
            var result = nodeWalker.GetNodeByPath(rootDirectory, null);

            // Assert
            Assert.AreEqual(rootDirectory, result);
        }
Exemplo n.º 3
0
        public void GetNodeByPath_StopAtLastExistingNodeAndPartialPathExists_ReturnsLowestExistingLevel()
        {
            // Arrange
            var nodeWalker    = new NodeWalker();
            var rootDirectory = new Directory {
                Name = "Root"
            };
            var childDirectory = new Directory {
                Name = "A"
            };

            rootDirectory.AddChild(childDirectory);
            var subChildDirectory = new Directory {
                Name = "C"
            };

            childDirectory.AddChild(subChildDirectory);

            // Act
            var result = nodeWalker.GetNodeByPath(rootDirectory, "A\\B", true);

            // Assert
            Assert.AreEqual(childDirectory, result);
        }
Exemplo n.º 4
0
        public void GetNodeByPath_PartialPathExists_ReturnsNull()
        {
            // Arrange
            var nodeWalker    = new NodeWalker();
            var rootDirectory = new Directory {
                Name = "Root"
            };
            var childDirectory = new Directory {
                Name = "A"
            };

            rootDirectory.AddChild(childDirectory);
            var subChildDirectory = new Directory {
                Name = "C"
            };

            childDirectory.AddChild(subChildDirectory);

            // Act
            var result = nodeWalker.GetNodeByPath(rootDirectory, "A\\B");

            // Assert
            Assert.IsNull(result);
        }