Example #1
0
        public void SingleNodeProducesSingleLine()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(new AdHocTree("root"), console);

            Assert.AreEqual(1, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
        }
Example #2
0
        public void NodeWithChildProducesTwoLinesConnected()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(new AdHocTree("root", new AdHocTree("child")), console);

            Assert.AreEqual(2, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("└─ child", console.GetOutputLines()[1]);
        }
Example #3
0
        public void DeepChildrenOfRootNode()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(
                new AdHocTree("root",
                              new AdHocTree("child",
                                            new AdHocTree("grandchild",
                                                          new AdHocTree("grandgrandchild")))), console);

            Assert.AreEqual(4, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("└─ child", console.GetOutputLines()[1]);
            Assert.AreEqual("  └─ grandchild", console.GetOutputLines()[2]);
            Assert.AreEqual("    └─ grandgrandchild", console.GetOutputLines()[3]);
        }
Example #4
0
        public void ManyChildrenOfRootNode()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(
                new AdHocTree("root",
                              new AdHocTree("child 1"),
                              new AdHocTree("child 2"),
                              new AdHocTree("child 3")),
                console);

            Assert.AreEqual(4, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("├─ child 1", console.GetOutputLines()[1]);
            Assert.AreEqual("├─ child 2", console.GetOutputLines()[2]);
            Assert.AreEqual("└─ child 3", console.GetOutputLines()[3]);
        }
Example #5
0
        public void MaxDepthConfigIsRespected()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(
                new AdHocTree("root",
                              new AdHocTree("child",
                                            new AdHocTree("grandchild 1"),
                                            new AdHocTree("grandchild 2",
                                                          new AdHocTree("grandgrandchild")))),
                console,
                new DisplayConfiguration {
                MaxDepth = 1
            });

            Assert.AreEqual(3, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("└─ child", console.GetOutputLines()[1]);
            Assert.AreEqual("  └─ (...)", console.GetOutputLines()[2]);
        }
Example #6
0
        public void JustAnotherDeepChildrenSituation()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(
                new AdHocTree("root",
                              new AdHocTree("child 1",
                                            new AdHocTree("grandchild 1",
                                                          new AdHocTree("grandgrandchild 1"),
                                                          new AdHocTree("grandgrandchild 2")),
                                            new AdHocTree("grandchild 2")),
                              new AdHocTree("child 2")), console);

            Assert.AreEqual(7, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("├─ child 1", console.GetOutputLines()[1]);
            Assert.AreEqual("│ ├─ grandchild 1", console.GetOutputLines()[2]);
            Assert.AreEqual("│ │ ├─ grandgrandchild 1", console.GetOutputLines()[3]);
            Assert.AreEqual("│ │ └─ grandgrandchild 2", console.GetOutputLines()[4]);
            Assert.AreEqual("│ └─ grandchild 2", console.GetOutputLines()[5]);
            Assert.AreEqual("└─ child 2", console.GetOutputLines()[6]);
        }
Example #7
0
        public void JustAnotherDeepChildrenSituationWithLinesTurnedOff()
        {
            var console = new StringBuilderConsole();

            CliTree.Print(
                new AdHocTree("root",
                              new AdHocTree("child 1",
                                            new AdHocTree("grandchild 1",
                                                          new AdHocTree("grandgrandchild 1"),
                                                          new AdHocTree("grandgrandchild 2")),
                                            new AdHocTree("grandchild 2")),
                              new AdHocTree("child 2")), console, new DisplayConfiguration {
                ShowLines = false
            });

            Assert.AreEqual(7, console.GetOutputLines().Count);
            Assert.AreEqual("root", console.GetOutputLines()[0]);
            Assert.AreEqual("  child 1", console.GetOutputLines()[1]);
            Assert.AreEqual("    grandchild 1", console.GetOutputLines()[2]);
            Assert.AreEqual("      grandgrandchild 1", console.GetOutputLines()[3]);
            Assert.AreEqual("      grandgrandchild 2", console.GetOutputLines()[4]);
            Assert.AreEqual("    grandchild 2", console.GetOutputLines()[5]);
            Assert.AreEqual("  child 2", console.GetOutputLines()[6]);
        }