예제 #1
0
        public Task Should_Render_Columns_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 61);
            var users   = new[]
            {
                new User {
                    Name = "Savannah Thompson", Country = "Australia"
                },
                new User {
                    Name = "Sophie Ramos", Country = "United States"
                },
                new User {
                    Name = "Katrin Goldberg", Country = "Germany"
                },
            };

            var cards = new List <Panel>();

            foreach (var user in users)
            {
                cards.Add(
                    new Panel($"[b]{user.Name}[/]\n[yellow]{user.Country}[/]")
                    .RoundedBorder().Expand());
            }

            // When
            console.Write(new Columns(cards));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #2
0
        public void Should_Throw_If_Tree_Contains_Cycles()
        {
            // Given
            var console = new FakeConsole(width: 80);

            var child2 = new TreeNode(new Text("child 2"));
            var child3 = new TreeNode(new Text("child 3"));
            var child1 = new TreeNode(new Text("child 1"));

            child1.AddNodes(child2, child3);
            var root = new TreeNode(new Text("Branch Node"));

            root.AddNodes(child1);
            child2.AddNode(root);

            var tree = new Tree("root node");

            tree.AddNodes(root);

            // When
            var result = Record.Exception(() => console.Write(tree));

            // Then
            result.ShouldBeOfType <CircularTreeException>();
        }
예제 #3
0
        public Task Should_Render_Table_With_Column_Justification_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var table   = new Table();

            table.AddColumn(new TableColumn("Foo")
            {
                Alignment = Justify.Left
            });
            table.AddColumn(new TableColumn("Bar")
            {
                Alignment = Justify.Right
            });
            table.AddColumn(new TableColumn("Baz")
            {
                Alignment = Justify.Center
            });
            table.AddRow("Qux", "Corgi", "Waldo");
            table.AddRow("Grault", "Garply", "Lorem ipsum dolor sit amet");

            // When
            console.Write(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #4
0
        public Task Should_Render_Tree_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);

            var tree = new Tree(new Text("Root node")).Guide(TreeGuide.DoubleLine);

            var nestedChildren = Enumerable.Range(0, 10).Select(x => new Text($"multiple\nline {x}"));
            var child2         = new TreeNode(new Text("child2"));
            var child2Child    = new TreeNode(new Text("child2-1"));

            child2.AddNode(child2Child);
            child2Child.AddNode(new TreeNode(new Text("Child2-1-1\nchild")));
            var child3      = new TreeNode(new Text("child3"));
            var child3Child = new TreeNode(new Text("single leaf\nmultiline"));

            child3Child.AddNode(new TreeNode(new Calendar(2021, 01)));
            child3.AddNode(child3Child);

            tree.AddNode("child1").AddNodes(nestedChildren);
            tree.AddNode(child2);
            tree.AddNode(child3);
            tree.AddNode("child4");

            // When
            console.Write(tree);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #5
0
        public Task Should_Render_Explicit_Grid_Column_Padding_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn(new GridColumn {
                Padding = new Padding(3, 0, 0, 0)
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(0, 0, 0, 0)
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(0, 0, 3, 0)
            });
            grid.AddRow("Foo", "Bar", "Baz");
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Write(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #6
0
        public Task Should_Render_Table_Nested_In_Panels_Correctly()
        {
            // A simple table
            var console = new FakeConsole(width: 80);
            var table   = new Table()
            {
                Border = TableBorder.Rounded
            };

            table.AddColumn("Foo");
            table.AddColumn("Bar");
            table.AddColumn(new TableColumn("Baz")
            {
                Alignment = Justify.Right
            });
            table.AddRow("Qux\nQuuuuuux", "[blue]Corgi[/]", "Waldo");
            table.AddRow("Grault", "Garply", "Fred");

            // Render a table in some panels.
            console.Write(new Panel(new Panel(table)
            {
                Border = BoxBorder.Ascii,
            }));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #7
0
        public Task Should_Render_Grid_Column_Alignment_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn(new GridColumn {
                Alignment = Justify.Right
            });
            grid.AddColumn(new GridColumn {
                Alignment = Justify.Center
            });
            grid.AddColumn(new GridColumn {
                Alignment = Justify.Left
            });
            grid.AddRow("Foo", "Bar", "Baz");
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Write(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #8
0
        public string Render()
        {
            var console = new FakeConsole();
            var context = new RenderContext(console.Profile.Capabilities);

            console.Write(Column.Render(context, Task, TimeSpan.Zero));
            return(console.Output);
        }
예제 #9
0
        public Task Should_Render_Default_Rule_With_Title_Centered_By_Default()
        {
            // Given
            var console = new FakeConsole(width: 40);

            // When
            console.Write(new Rule("Hello World"));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #10
0
        public Task Should_Render_Panel_Inside_Panel_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);

            // When
            console.Write(new Panel(new Panel(new Text("Hello World"))));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #11
0
        public Task Should_Render_Default_Rule_Without_Title()
        {
            // Given
            var console = new FakeConsole(width: 40);

            // When
            console.Write(new Rule());

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #12
0
        public Task Should_Render_With_Specified_Box()
        {
            // Given
            var console = new FakeConsole(width: 40);

            // When
            console.Write(new Rule("Hello World").DoubleBorder());

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #13
0
        public Task Should_Truncate_Title()
        {
            // Given
            var console = new FakeConsole(width: 40);

            // When
            console.Write(new Rule("          Hello World    "));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #14
0
        public Task Should_Render_Panel_With_Multiple_Lines()
        {
            // Given
            var console = new FakeConsole(width: 80);

            // When
            console.Write(new Panel(new Text("Hello World\nFoo Bar")));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #15
0
        public Task Should_Convert_Line_Breaks_In_Title_To_Spaces()
        {
            // Given
            var console = new FakeConsole(width: 40);

            // When
            console.Write(new Rule("Hello\nWorld\r\n!"));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #16
0
        public Task Should_Render_Panel_With_Unicode_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);

            // When
            console.Write(new Panel(new Text(" \n💩\n ")));

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #17
0
        public void Should_Truncate_Too_Long_Title(int width, string input, string expected)
        {
            // Given
            var console = new FakeConsole(width);

            // When
            console.Write(new Rule(input));

            // Then
            console.Lines.Count.ShouldBe(1);
            console.Lines[0].ShouldBe(expected);
        }
예제 #18
0
            public Task Should_Render_As_Expected()
            {
                // Given
                var console = new FakeConsole();
                var panel   = Fixture.GetPanel().DoubleBorder();

                // When
                console.Write(panel);

                // Then
                return(Verifier.Verify(console.Output));
            }
예제 #19
0
        public void Should_Render_Links_As_Expected(string input, string output)
        {
            // Given
            var console = new FakeConsole();
            var markup  = new Markup(input);

            // When
            console.Write(markup);

            // Then
            console.Output.ShouldBe(output);
        }
예제 #20
0
        public void Should_Render_Unstyled_Text_As_Expected()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var text    = new Text("Hello World");

            // When
            console.Write(text);

            // Then
            console.Output.ShouldBe("Hello World");
        }
예제 #21
0
            public Task Should_Render_Right_Aligned_Table_Columns_As_Expected()
            {
                // Given
                var console = new FakeConsole();
                var table   = Fixture.GetTable(header2: Justify.Right).MarkdownBorder();

                // When
                console.Write(table);

                // Then
                return(Verifier.Verify(console.Output));
            }
예제 #22
0
            public Task Should_Render_As_Expected()
            {
                // Given
                var console = new FakeConsole();
                var table   = Fixture.GetTable().AsciiBorder();

                // When
                console.Write(table);

                // Then
                return(Verifier.Verify(console.Output));
            }
예제 #23
0
        public async Task Should_Render_Correctly_With_Specific_Culture()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var chart   = Fixture.GetChart().Width(60).Culture("sv-SE");

            // When
            console.Write(chart);

            // Then
            await Verifier.Verify(console.Output);
        }
예제 #24
0
        public async Task Should_Render_Correctly_Without_Tag_Values()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var chart   = Fixture.GetChart().Width(60).HideTagValues();

            // When
            console.Write(chart);

            // Then
            await Verifier.Verify(console.Output);
        }
예제 #25
0
        public async Task Should_Render_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var chart   = Fixture.GetChart();

            // When
            console.Write(chart);

            // Then
            await Verifier.Verify(console.Output);
        }
예제 #26
0
        public Task Should_Render_Tree_With_No_Child_Nodes_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 80);
            var tree    = new Tree(new Text("Root node"));

            // When
            console.Write(tree);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #27
0
        public void Should_Write_Line_Breaks(string input)
        {
            // Given
            var console = new FakeConsole(width: 5);
            var text    = new Text(input);

            // When
            console.Write(text);

            // Then
            console.Output.ShouldBe("Hello\n\nWorld\n\n");
        }
예제 #28
0
        public async Task Should_Render_Wrapped_Text_Correctly()
        {
            // Given
            var console = new FakeConsole(width: 70);
            var text    = new FigletText(FigletFont.Default, "Spectre.Console");

            // When
            console.Write(text);

            // Then
            await Verifier.Verify(console.Output);
        }
예제 #29
0
        public void Should_Escape_Markup_Blocks_As_Expected()
        {
            // Given
            var console = new FakeConsole();
            var markup  = new Markup("Hello [[ World ]] !");

            // When
            console.Write(markup);

            // Then
            console.Output.ShouldBe("Hello [ World ] !");
        }
예제 #30
0
        public void Should_Render_Panel_2()
        {
            // Given
            var console = new FakeConsole(width: 80);

            // When
            console.Write(new Markup("[b]Hello World[/]\n[yellow]Hello World[/]"));

            // Then
            console.Lines.Count.ShouldBe(2);
            console.Lines[0].ShouldBe("Hello World");
            console.Lines[1].ShouldBe("Hello World");
        }