public Task Should_Right_Align_Calendar_Correctly()
        {
            // Given
            var console  = new PlainConsole(width: 80);
            var calendar = new Calendar(2020, 10)
                           .RightAligned()
                           .AddCalendarEvent(new DateTime(2020, 9, 1))
                           .AddCalendarEvent(new DateTime(2020, 10, 3))
                           .AddCalendarEvent(new DateTime(2020, 10, 12));

            // When
            console.Render(calendar);

            // Then
            return(Verifier.Verify(console.Output));
        }
        public void Should_Render_Panel_With_Unicode_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);

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

            // Then
            console.Lines.Count.ShouldBe(5);
            console.Lines[0].ShouldBe("┌────┐");
            console.Lines[1].ShouldBe("│    │");
            console.Lines[2].ShouldBe("│ 💩 │");
            console.Lines[3].ShouldBe("│    │");
            console.Lines[4].ShouldBe("└────┘");
        }
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().NoBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(4);
                console.Lines[0].ShouldBe("Header 1 Header 2");
                console.Lines[1].ShouldBe("Cell     Cell    ");
                console.Lines[2].ShouldBe("Cell     Cell    ");
                console.Lines[3].ShouldBe("Footer 1 Footer 2");
            }
        public Task Should_Render_Calendar_Correctly_For_Specific_Culture()
        {
            // Given
            var console  = new PlainConsole(width: 80);
            var calendar = new Calendar(2020, 10, 15)
                           .Culture("de-DE")
                           .AddCalendarEvent(new DateTime(2020, 9, 1))
                           .AddCalendarEvent(new DateTime(2020, 10, 3))
                           .AddCalendarEvent(new DateTime(2020, 10, 12));

            // When
            console.Render(calendar);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #5
0
        public Task Should_Render_Table_With_Multiple_Rows_In_Cell_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var table   = new Table();

            table.AddColumns("Foo", "Bar", "Baz");
            table.AddRow("Qux\nQuuux", "Corgi", "Waldo");
            table.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #6
0
        public void Should_Render_Panel_Inside_Panel_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);

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

            // Then
            console.Lines.Count.ShouldBe(5);
            console.Lines[0].ShouldBe("┌─────────────────┐");
            console.Lines[1].ShouldBe("│ ┌─────────────┐ │");
            console.Lines[2].ShouldBe("│ │ Hello World │ │");
            console.Lines[3].ShouldBe("│ └─────────────┘ │");
            console.Lines[4].ShouldBe("└─────────────────┘");
        }
Beispiel #7
0
        public Task Should_Right_Align_Table_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var table   = new Table();

            table.Alignment = Justify.Right;
            table.AddColumns("Foo", "Bar", "Baz");
            table.AddRow("Qux", "Corgi", "Waldo");
            table.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #8
0
            public Task Should_Add_Empty_Row()
            {
                // Given
                var console = new PlainConsole(width: 80);
                var grid    = new Grid();

                grid.AddColumns(2);
                grid.AddRow("Foo", "Bar");
                grid.AddEmptyRow();
                grid.AddRow("Qux", "Corgi");

                // When
                console.Render(grid);

                // Then
                return(Verifier.Verify(console.Output));
            }
        public void Should_Render_Panel_With_Padding()
        {
            // Given
            var console = new PlainConsole(width: 80);

            // When
            console.Render(new Panel(new Text("Hello World"))
            {
                Padding = new Padding(3, 5),
            });

            // Then
            console.Lines.Count.ShouldBe(3);
            console.Lines[0].ShouldBe("┌───────────────────┐");
            console.Lines[1].ShouldBe("│   Hello World     │");
            console.Lines[2].ShouldBe("└───────────────────┘");
        }
Beispiel #10
0
        public Task Should_Use_Default_Padding()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumns(3);
            grid.AddRow("Foo", "Bar", "Baz");
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #11
0
        public Task Should_Render_Padded_Object_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 60);
            var table   = new Table();

            table.AddColumn("Foo");
            table.AddColumn("Bar");
            table.AddRow("Baz", "Qux");
            table.AddRow("Corgi", "Waldo");

            // When
            console.Render(new Padder(table).Padding(1, 2, 3, 4));

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #12
0
        public void Should_Justify_Child_To_Center()
        {
            // Given
            var console = new PlainConsole(width: 25);

            // When
            console.Render(
                new Panel(new Text("Hello World").Centered())
            {
                Expand = true,
            });

            // Then
            console.Lines.Count.ShouldBe(3);
            console.Lines[0].ShouldBe("┌───────────────────────┐");
            console.Lines[1].ShouldBe("│      Hello World      │");
            console.Lines[2].ShouldBe("└───────────────────────┘");
        }
Beispiel #13
0
        public void Should_Expand_Panel_If_Enabled()
        {
            // Given
            var console = new PlainConsole(width: 80);

            // When
            console.Render(new Panel(new Text("Hello World"))
            {
                Expand = true,
            });

            // Then
            console.Lines.Count.ShouldBe(3);
            console.Lines[0].Length.ShouldBe(80);
            console.Lines[0].ShouldBe("┌──────────────────────────────────────────────────────────────────────────────┐");
            console.Lines[1].ShouldBe("│ Hello World                                                                  │");
            console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘");
        }
Beispiel #14
0
            public void Should_Render_Right_Aligned_Table_Columns_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable(header2: Justify.Right).MarkdownBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("                       ");
                console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
                console.Lines[2].ShouldBe("| -------- | -------: |");
                console.Lines[3].ShouldBe("| Cell     |     Cell |");
                console.Lines[4].ShouldBe("| Cell     |     Cell |");
                console.Lines[5].ShouldBe("                       ");
            }
Beispiel #15
0
        public Task Should_Render_Table_With_Footers_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var table   = new Table();

            table.AddColumn(new TableColumn("Foo").Footer("Oof").RightAligned());
            table.AddColumn("Bar");
            table.AddColumns(new TableColumn("Baz").Footer("Zab"));
            table.AddRow("Qux", "Corgi", "Waldo");
            table.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #16
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().AsciiBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("+---------------------+");
                console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
                console.Lines[2].ShouldBe("|----------+----------|");
                console.Lines[3].ShouldBe("| Cell     | Cell     |");
                console.Lines[4].ShouldBe("| Cell     | Cell     |");
                console.Lines[5].ShouldBe("+---------------------+");
            }
Beispiel #17
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().HeavyEdgeBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("┏━━━━━━━━━━┯━━━━━━━━━━┓");
                console.Lines[1].ShouldBe("┃ Header 1 │ Header 2 ┃");
                console.Lines[2].ShouldBe("┠──────────┼──────────┨");
                console.Lines[3].ShouldBe("┃ Cell     │ Cell     ┃");
                console.Lines[4].ShouldBe("┃ Cell     │ Cell     ┃");
                console.Lines[5].ShouldBe("┗━━━━━━━━━━┷━━━━━━━━━━┛");
            }
Beispiel #18
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().HeavyHeadBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓");
                console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃");
                console.Lines[2].ShouldBe("┡━━━━━━━━━━╇━━━━━━━━━━┩");
                console.Lines[3].ShouldBe("│ Cell     │ Cell     │");
                console.Lines[4].ShouldBe("│ Cell     │ Cell     │");
                console.Lines[5].ShouldBe("└──────────┴──────────┘");
            }
Beispiel #19
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().SimpleHeavyBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("                       ");
                console.Lines[1].ShouldBe("  Header 1   Header 2  ");
                console.Lines[2].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━");
                console.Lines[3].ShouldBe("  Cell       Cell      ");
                console.Lines[4].ShouldBe("  Cell       Cell      ");
                console.Lines[5].ShouldBe("                       ");
            }
Beispiel #20
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().MinimalDoubleHeadBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("                       ");
                console.Lines[1].ShouldBe("  Header 1 │ Header 2  ");
                console.Lines[2].ShouldBe(" ══════════╪══════════ ");
                console.Lines[3].ShouldBe("  Cell     │ Cell      ");
                console.Lines[4].ShouldBe("  Cell     │ Cell      ");
                console.Lines[5].ShouldBe("                       ");
            }
Beispiel #21
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().RoundedBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("╭──────────┬──────────╮");
                console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │");
                console.Lines[2].ShouldBe("├──────────┼──────────┤");
                console.Lines[3].ShouldBe("│ Cell     │ Cell     │");
                console.Lines[4].ShouldBe("│ Cell     │ Cell     │");
                console.Lines[5].ShouldBe("╰──────────┴──────────╯");
            }
Beispiel #22
0
        public void Should_Render_Panel_With_Centered_Header()
        {
            // Given
            var console = new PlainConsole(width: 80);

            // When
            console.Render(new Panel("Hello World")
            {
                Header = new Header("Greeting").Centered(),
                Expand = true,
            });

            // Then
            console.Lines.Count.ShouldBe(3);
            console.Lines[0].ShouldBe("┌───────────────────────────────────Greeting───────────────────────────────────┐");
            console.Lines[1].ShouldBe("│ Hello World                                                                  │");
            console.Lines[2].ShouldBe("└──────────────────────────────────────────────────────────────────────────────┘");
        }
Beispiel #23
0
            public void Should_Render_As_Expected()
            {
                // Given
                var console = new PlainConsole();
                var table   = Fixture.GetTable().DoubleEdgeBorder();

                // When
                console.Render(table);

                // Then
                console.Lines.Count.ShouldBe(6);
                console.Lines[0].ShouldBe("╔══════════╤══════════╗");
                console.Lines[1].ShouldBe("║ Header 1 │ Header 2 ║");
                console.Lines[2].ShouldBe("╟──────────┼──────────╢");
                console.Lines[3].ShouldBe("║ Cell     │ Cell     ║");
                console.Lines[4].ShouldBe("║ Cell     │ Cell     ║");
                console.Lines[5].ShouldBe("╚══════════╧══════════╝");
            }
Beispiel #24
0
        public Task Should_Render_Table_Without_Rows()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var table   = new Table();

            table.AddColumns("Foo", "Bar");
            table.AddColumn(new TableColumn("Baz")
            {
                Padding = new Padding(3, 0, 2, 0)
            });

            // When
            console.Render(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #25
0
        public Task Should_Render_Grid_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn();
            grid.AddColumn();
            grid.AddColumn();
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #26
0
        public void Should_Collapse_Header_If_It_Will_Not_Fit()
        {
            // Given
            var console = new PlainConsole(width: 10);

            // When
            console.Render(new Panel("Hello World")
            {
                Header = new Header("Greeting"),
                Expand = true,
            });

            // Then
            console.Lines.Count.ShouldBe(4);
            console.Lines[0].ShouldBe("┌─Greet…─┐");
            console.Lines[1].ShouldBe("│ Hello  │");
            console.Lines[2].ShouldBe("│ World  │");
            console.Lines[3].ShouldBe("└────────┘");
        }
Beispiel #27
0
        public Task Should_Expand_Table_To_Available_Space_If_Specified()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var table   = new Table()
            {
                Expand = true
            };

            table.AddColumns("Foo", "Bar", "Baz");
            table.AddRow("Qux", "Corgi", "Waldo");
            table.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(table);

            // Then
            return(Verifier.Verify(console.Output));
        }
Beispiel #28
0
            public void Should_Add_Empty_Row()
            {
                // Given
                var console = new PlainConsole(width: 80);
                var grid    = new Grid();

                grid.AddColumns(2);
                grid.AddRow("Foo", "Bar");
                grid.AddEmptyRow();
                grid.AddRow("Qux", "Corgi");

                // When
                console.Render(grid);

                // Then
                console.Lines.Count.ShouldBe(3);
                console.Lines[0].ShouldBe("Foo  Bar  ");
                console.Lines[1].ShouldBe("          ");
                console.Lines[2].ShouldBe("Qux  Corgi");
            }
Beispiel #29
0
        public void Should_Use_Default_Padding()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumns(3);
            grid.AddRow("Foo", "Bar", "Baz");
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(grid);

            // Then
            console.Lines.Count.ShouldBe(3);
            console.Lines[0].ShouldBe("Foo     Bar     Baz  ");
            console.Lines[1].ShouldBe("Qux     Corgi   Waldo");
            console.Lines[2].ShouldBe("Grault  Garply  Fred ");
        }
Beispiel #30
0
        public void Should_Render_Grid_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn();
            grid.AddColumn();
            grid.AddColumn();
            grid.AddRow("Qux", "Corgi", "Waldo");
            grid.AddRow("Grault", "Garply", "Fred");

            // When
            console.Render(grid);

            // Then
            console.Lines.Count.ShouldBe(2);
            console.Lines[0].ShouldBe("Qux     Corgi   Waldo");
            console.Lines[1].ShouldBe("Grault  Garply  Fred ");
        }