コード例 #1
0
        public void Column_widths_are_aligned_to_the_longest_cell_in_file_mode()
        {
            var options = new[] {
                new Option("-s", "an option"),
                new Option("--very-long", "an option")
            };

            var view = new OptionsHelpView(options);

            view.Render(new ConsoleRenderer(_console, OutputMode.File), new Region(0, 0, 30, 3));

            var lines = _console.Out.ToString()
                        .Split(NewLine)
                        .ToArray();

            lines[1].IndexOf("an option")
            .Should()
            .Be(lines[2].IndexOf("an option"));
        }
コード例 #2
0
        public void Column_widths_are_aligned_to_the_longest_cell(OutputMode outputMode)
        {
            var options = new[] {
                new Option("-s", "an option"),
                new Option("--very-long", "an option")
            };

            var view = new OptionsHelpView(options);

            view.Render(new ConsoleRenderer(_console, outputMode), new Region(0, 0, 30, 3));

            var lines = _console.RenderOperations()
                        .Select(l => l.Text)
                        .ToArray();

            lines[1].IndexOf("an option")
            .Should()
            .Be(lines[2].IndexOf("an option"));
        }
コード例 #3
0
        public void A_row_is_written_for_each_item_and_a_header_for_each_column_in_file_mode()
        {
            var options = new[]
            {
                new Option("-s", "a short option"),
                new Option("--very-long", "a long option")
            };

            var view = new OptionsHelpView(options);

            view.Render(new ConsoleRenderer(_console, OutputMode.File), new Region(0, 0, 30, 3));

            _console.Out
            .ToString()
            .Should()
            .Be(
                "Option                     " + NewLine +
                "-s           a short option" + NewLine +
                "--very-long  a long option ");
        }
コード例 #4
0
        public void A_row_is_written_for_each_item_and_a_header_for_each_column(OutputMode outputMode)
        {
            var options = new[] {
                new Option("-s", "a short option"),
                new Option("--very-long", "a long option")
            };

            var view = new OptionsHelpView(options);

            view.Render(new ConsoleRenderer(_console, outputMode), new Region(0, 0, 30, 3));

            var lines = _console.RenderOperations();

            lines
            .Should()
            .BeEquivalentSequenceTo(
                Cell("Option       ", 0, 0), Cell("              ", 13, 0),
                Cell("-s           ", 0, 1), Cell("a short option", 13, 1),
                Cell("--very-long  ", 0, 2), Cell("a long option ", 13, 2));
        }