예제 #1
0
        public void Should_Render_Grid_Column_Alignment_Correctly()
        {
            // Given
            var console = new PlainConsole(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.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 ");
        }
예제 #2
0
        public GeneralRequestVisualizer()
        {
            title = NameValuePanel.Create("Title", new TextBox());

            var url    = NameValuePanel.Create("URL", new TextBox());
            var method = new ComboBox
            {
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin            = new Thickness(0, 0, 5, 0),
                SelectedIndex     = 0
            };

            var urlAndMethod = new Grid();

            urlAndMethod.AddColumn(1, GridUnitType.Star);
            urlAndMethod.AddColumn(100, GridUnitType.Pixel);
            urlAndMethod.AddRow(GridLength.Auto);
            urlAndMethod.Add(url, 0, 0);
            urlAndMethod.Add(method, 0, 1);

            var apiGeneralStackPanel = new StackPanel
            {
                Margin = new Thickness(0, 0, 0, 10)
            };

            apiGeneralStackPanel.Children.Add(title);
            apiGeneralStackPanel.Children.Add(urlAndMethod);
            Children.Add(apiGeneralStackPanel);

            this.Bind(x => x.Model.Title).Mate(title.Value);
            this.Bind(x => x.Model.Url).Mate(url.Value);
            this.Bind(x => x.Model.Method).Mate(method, x => x.MainWindow.Methods);
        }
예제 #3
0
        public Task Should_Render_Explicit_Grid_Column_Padding_Correctly()
        {
            // Given
            var console = new PlainConsole(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.Render(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #4
0
        public void Should_Wrap_Content_Correctly()
        {
            // Given
            var console = new PlainConsole(width: 84);
            var rows    = new List <IRenderable>();
            var grid    = new Grid();

            grid.AddColumn(new GridColumn().PadLeft(2).PadRight(0));
            grid.AddColumn(new GridColumn().PadLeft(1).PadRight(0));
            grid.AddRow("at", "[grey]System.Runtime.CompilerServices.TaskAwaiter.[/][yellow]HandleNonSuccessAndDebuggerNotification[/]([blue]Task[/] task)");
            rows.Add(grid);

            var panel = new Panel(grid)
                        .Expand().RoundedBorder()
                        .SetBorderStyle(Style.WithForeground(Color.Grey))
                        .SetHeader("Short paths ", Style.WithForeground(Color.Grey));

            // When
            console.Render(panel);

            // Then
            console.Lines.Count.ShouldBe(4);
            console.Lines[0].ShouldBe("╭─Short paths ─────────────────────────────────────────────────────────────────────╮");
            console.Lines[1].ShouldBe("│   at System.Runtime.CompilerServices.TaskAwaiter.                                │");
            console.Lines[2].ShouldBe("│      HandleNonSuccessAndDebuggerNotification(Task task)                          │");
            console.Lines[3].ShouldBe("╰──────────────────────────────────────────────────────────────────────────────────╯");
        }
예제 #5
0
        public void Should_Render_Grid()
        {
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn(new GridColumn {
                NoWrap = true
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(2, 0, 0, 0)
            });
            grid.AddRow("[bold]Options[/]", string.Empty);
            grid.AddRow("  [blue]-h[/], [blue]--help[/]", "Show command line help.");
            grid.AddRow("  [blue]-c[/], [blue]--configuration[/]", "The configuration to run for.\nThe default for most projects is [green]Debug[/].");

            // When
            console.Render(grid);

            // Then
            console.Lines.Count.ShouldBe(4);
            console.Lines[0].ShouldBe("Options                                                         ");
            console.Lines[1].ShouldBe("  -h, --help             Show command line help.                ");
            console.Lines[2].ShouldBe("  -c, --configuration    The configuration to run for.          ");
            console.Lines[3].ShouldBe("                         The default for most projects is Debug.");
        }
예제 #6
0
        private static void ConfigureCrudButtons(Grid grid, GridMetamodel gridModel)
        {
            if (gridModel.DetailsLink.IsEnabled)
            {
                grid.AddColumn(new Column("DetailsLink")
                               .SetLabel(gridModel.DetailsLink.Text)
                               .SetWidth(70).SetFixedWidth(true)
                               .SetSortable(false)
                               .SetSearch(false)
                               .SetCustomFormatter("buildDetailsLink"));
            }

            if (gridModel.EditLink.IsEnabled)
            {
                grid.AddColumn(new Column("EditLink")
                               .SetLabel(gridModel.EditLink.Text)
                               .SetWidth(50).SetFixedWidth(true)
                               .SetSortable(false)
                               .SetSearch(false)
                               .SetCustomFormatter("buildEditLink"));
            }

            if (gridModel.DeleteLink.IsEnabled)
            {
                grid.AddColumn(new Column("DeleteLink")
                               .SetLabel(gridModel.DeleteLink.Text)
                               .SetWidth(50).SetFixedWidth(true)
                               .SetSortable(false)
                               .SetSearch(false)
                               .SetCustomFormatter("buildDeleteLink"));
            }
        }
예제 #7
0
        public void Should_Render_Explicit_Grid_Column_Padding_Correctly()
        {
            // Given
            var console = new PlainConsole(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.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("   GraultGarplyFred    ");
        }
예제 #8
0
        private static IEnumerable <IRenderable> GetOptions(CommandModel model, CommandInfo?command)
        {
            // Collect all options into a single structure.
            var parameters = HelpOption.Get(model, command);

            if (parameters.Count == 0)
            {
                return(Array.Empty <IRenderable>());
            }

            var result = new List <IRenderable>
            {
                new Markup(Environment.NewLine),
                new Markup("[yellow]OPTIONS:[/]"),
                new Markup(Environment.NewLine),
            };

            var grid = new Grid();

            grid.AddColumn(new GridColumn {
                Padding = new Padding(4, 4), NoWrap = true
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(0, 0)
            });
예제 #9
0
        private Grid GenerateActivityGrid()
        {
            DateTime to;
            DateTime @from;
            var      userId = GetQueryParas(out to, out @from);

            var totActivities = PatService.GetActivities(userId, from, to).Count;

            var g = new Grid("activity");

            g.AddColumn(new Column("rowNo").SetLabel("#").SetWidth(60).SetAlign(Align.Right));
            g.AddColumn(new Column("ActivityId").SetLabel("Activity Id").SetWidth(60).SetAlign(Align.Center));
            g.AddColumn(new Column("UserId").SetLabel("UserId").SetWidth(60).SetAlign(Align.Center));
            g.AddColumn(new Column("Activity").SetLabel("Activity").SetWidth(200));

            g.AddColumn(new Column("CreatedOn").SetLabel("Date").SetWidth(80));
            g.SetUrl(VirtualPathUtility.ToAbsolute("~/Home/GridDataActivity"));

            g.SetHeight(CommonConstants.GridStandardHeight); //  set this tall enough and you wont see the scroll bars
            g.SetWidth(CommonConstants.GridStandardWidth);
            g.SetAutoWidth(true);                            //  will force the grid to fit the width of the parent element
            g.SetRowNum(totActivities);                      //  Sets the number of rows displayed initially
            g.SetViewRecords(true);                          //  isplays the total number of rows in the dataset
            return(g);
        }
예제 #10
0
        public Task Should_Render_Grid_Column_Alignment_Correctly()
        {
            // Given
            var console = new PlainConsole(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.Render(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #11
0
    private static IRenderable GetTextGrid()
    {
        var loremTable = new Grid();
        var lorem      = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque in metus sed sapien ultricies pretium a at justo. Maecenas luctus velit et auctor maximus.";

        loremTable.AddColumn(new GridColumn().LeftAligned());
        loremTable.AddColumn(new GridColumn().Centered());
        loremTable.AddColumn(new GridColumn().RightAligned());
        loremTable.AddRow($"[green]{lorem}[/]", $"[yellow]{lorem}[/]", $"[blue]{lorem}[/]");
        return(loremTable);
    }
예제 #12
0
        public void CanAddMultipleColumnsFromList()
        {
            var grid = new Grid("testGrid");
            grid.AddColumn(new Column("testColumn1"));
            grid.AddColumn(new Column("testColumn2"));

            StringAssert.Contains("name:'testColumn1',", grid.ToString());
            StringAssert.Contains("index:'testColumn1'", grid.ToString());
            StringAssert.Contains("name:'testColumn2',", grid.ToString());
            StringAssert.Contains("index:'testColumn2'", grid.ToString());
            JavascriptAssert.IsValid(grid.RenderJavascript());
        }
예제 #13
0
        private static Grid GetStackFrames(ExceptionInfo ex, ExceptionSettings settings)
        {
            var styles = settings.Style;

            var grid = new Grid();

            grid.AddColumn(new GridColumn().PadLeft(2).PadRight(0).NoWrap());
            grid.AddColumn(new GridColumn().PadLeft(1).PadRight(0));

            // Inner
            if (ex.Inner != null)
            {
                grid.AddRow(
                    Text.Empty,
                    GetException(ex.Inner, settings));
            }

            // Stack frames
            foreach (var frame in ex.Frames)
            {
                var builder = new StringBuilder();

                // Method
                var shortenMethods = (settings.Format & ExceptionFormats.ShortenMethods) != 0;
                builder.Append(Emphasize(frame.Method, new[] { '.' }, styles.Method, shortenMethods, settings));
                builder.AppendWithStyle(styles.Parenthesis, "(");
                AppendParameters(builder, frame, settings);
                builder.AppendWithStyle(styles.Parenthesis, ")");

                if (frame.Path != null)
                {
                    builder.Append(' ');
                    builder.AppendWithStyle(styles.Dimmed, "in");
                    builder.Append(' ');

                    // Path
                    AppendPath(builder, frame, settings);

                    // Line number
                    if (frame.LineNumber != null)
                    {
                        builder.AppendWithStyle(styles.Dimmed, ":");
                        builder.AppendWithStyle(styles.LineNumber, frame.LineNumber);
                    }
                }

                grid.AddRow(
                    $"[{styles.Dimmed.ToMarkup()}]at[/]",
                    builder.ToString());
            }

            return(grid);
        }
예제 #14
0
        public void CanAddMultipleColumnsFromList()
        {
            var grid = new Grid("testGrid");

            grid.AddColumn(new Column("testColumn1"));
            grid.AddColumn(new Column("testColumn2"));

            StringAssert.Contains("name:'testColumn1',", grid.ToString());
            StringAssert.Contains("index:'testColumn1'", grid.ToString());
            StringAssert.Contains("name:'testColumn2',", grid.ToString());
            StringAssert.Contains("index:'testColumn2'", grid.ToString());
            JavascriptAssert.IsValid(grid.RenderJavascript());
        }
예제 #15
0
            public void Should_Add_Empty_Items_If_User_Provides_Less_Row_Items_Than_Columns()
            {
                // Given
                var grid = new Grid();

                grid.AddColumn();
                grid.AddColumn();

                // When
                grid.AddRow("Foo");

                // Then
                grid.Rows.Count.ShouldBe(1);
            }
예제 #16
0
            public void Should_Throw_If_Rows_Are_Not_Empty()
            {
                // Given
                var grid = new Grid();

                grid.AddColumn();
                grid.AddRow("Hello World!");

                // When
                var result = Record.Exception(() => grid.AddColumn());

                // Then
                result.ShouldBeOfType <InvalidOperationException>()
                .Message.ShouldBe("Cannot add new columns to grid with existing rows.");
            }
예제 #17
0
    /// <inheritdoc/>
    protected override IEnumerable <Segment> Render(RenderContext context, int maxWidth)
    {
        var width = Math.Min(Width ?? maxWidth, maxWidth);

        var grid = new Grid().Width(width);

        grid.AddColumn(new GridColumn().NoWrap());

        // Bar
        grid.AddRow(new BreakdownBar(Data)
        {
            Width = width,
        });

        if (ShowTags)
        {
            if (!Compact)
            {
                grid.AddEmptyRow();
            }

            // Tags
            grid.AddRow(new BreakdownTags(Data)
            {
                Width          = width,
                Culture        = Culture,
                ShowTagValues  = ShowTagValues,
                ValueFormatter = ValueFormatter,
            });
        }

        return(((IRenderable)grid).Render(context, width));
    }
예제 #18
0
        /// <summary>
        /// Called when initialized.
        /// </summary>
        protected override void OnInitialized()
        {
            if (Grid != null)
            {
                Grid.AddColumn(this);

                if (!string.IsNullOrEmpty(FilterProperty) || Type == null)
                {
                    var property = GetFilterProperty();

                    if (!string.IsNullOrEmpty(property))
                    {
                        _filterPropertyType = PropertyAccess.GetPropertyType(typeof(TItem), property);
                    }
                }

                if (_filterPropertyType == null)
                {
                    _filterPropertyType = Type;
                }
                else
                {
                    propertyValueGetter = PropertyAccess.Getter <TItem, object>(Property);
                }

                if (_filterPropertyType == typeof(string))
                {
                    FilterOperator = FilterOperator.Contains;
                }
            }
        }
예제 #19
0
        private int List(Settings settings)
        {
            var examples = _finder.FindExamples();

            if (examples.Count == 0)
            {
                AnsiConsole.Markup("[yellow]No examples could be found.[/]");
                return(0);
            }

            AnsiConsole.WriteLine();

            var rows = new Grid().Collapse();

            rows.AddColumn();
            foreach (var group in examples.GroupBy(ex => ex.Group))
            {
                rows.AddRow(CreateTable(settings, group.Key, group));
                rows.AddEmptyRow();
            }

            AnsiConsole.Render(rows);

            AnsiConsole.MarkupLine("Type [blue]dotnet example --help[/] for help");

            return(0);
        }
예제 #20
0
 public void AddColumn(int targetIndex)
 {
     isListeningGridUpdates = false;
     Grid.AddColumn(targetIndex);
     isListeningGridUpdates = true;
     SaveGridState();
 }
예제 #21
0
            public static void IsValid(Column column)
            {
                var grid = new Grid("test");

                grid.AddColumn(column);

                JavascriptAssert.IsValid(grid.RenderJavascript());
            }
        public GroupTestSyncfusion()
        {
            InitializeComponent();

            Grid.AddColumn <int>(AccountColumns.PersonId);
            Grid.AddColumn <int>(GroupTestViewModel.CountColumnId);
            Grid.AddColumn <decimal>(GroupTestViewModel.SumColumnId);
        }
예제 #23
0
    public static void Main()
    {
        AnsiConsole.WriteLine();
        AnsiConsole.MarkupLine("Usage: [grey]dotnet [blue]run[/] [[options]] [[[[--]] <additional arguments>...]]]][/]");
        AnsiConsole.WriteLine();

        var grid = new Grid();

        grid.AddColumn(new GridColumn().NoWrap());
        grid.AddColumn(new GridColumn().PadLeft(2));
        grid.AddRow("Options:");
        grid.AddRow("  [blue]-h[/], [blue]--help[/]", "Show command line help.");
        grid.AddRow("  [blue]-c[/], [blue]--configuration[/] <CONFIGURATION>", "The configuration to run for.");
        grid.AddRow("  [blue]-v[/], [blue]--verbosity[/] <LEVEL>", "Set the [grey]MSBuild[/] verbosity level.");

        AnsiConsole.Write(grid);
    }
예제 #24
0
        private Grid GenerateSampleGrid(string sessionKey)
        {
            var totRecs = PatService.GetSample(sessionKey).Count;
            var g       = new Grid("sample");

            g.AddColumn(new Column("rowNumber").SetLabel("#").SetWidth(50).SetFixedWidth(true).SetAlign(Align.Right).SetSortable(false));
            g.AddColumn(new Column("ClaimId").SetLabel(CommonConstants.ReviewColumnClaimId).SetWidth(70).SetFixedWidth(true).SetSortable(false));
            g.AddColumn(new Column("JobseekerId").SetLabel(CommonConstants.ReviewColumnJobseekerId).SetWidth(70).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("Amount").SetLabel(CommonConstants.ReviewColumnClaimAmount).SetWidth(60).SetAlign(Align.Right).SetFixedWidth(true).SetSortable(false));
            g.AddColumn(new Column("ManualSpecialClaimFlag").SetLabel(CommonConstants.ReviewColumnManualSpecialClaim).SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("AutoSpecialClaimFlag").SetLabel(CommonConstants.ReviewColumnAutoSpecialClaim).SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
            g.AddColumn(new Column("ClaimStatusDesc").SetLabel("Claim Status").SetWidth(80).SetFixedWidth(true).SetAlign(Align.Center).SetSortable(false));
#if DEBUG
            //g.AddColumn( new Column( "ClaimType" ).SetLabel( "Type" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "CreationDate" ).SetLabel( "Date" ).SetWidth( 60 ).SetFixedWidth( true ).SetAlign( Align.Right ) );

            //g.AddColumn( new Column( "OrgCode" ).SetLabel( "OrgCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "OrgDesc" ).SetLabel( "Org" ).SetWidth( 150 ).SetFixedWidth( true ) );
            //g.AddColumn( new Column( "EsaCode" ).SetLabel( "EsaCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "SiteCode" ).SetLabel( "SiteCode" ).SetWidth( 70 ).SetFixedWidth( true ).SetAlign( Align.Center ) );
            //g.AddColumn( new Column( "SiteDesc" ).SetLabel( "Site" ).SetWidth( 210 ).SetFixedWidth( true ) );
#endif
            g.SetHeight(CommonConstants.GridStandardHeight);
            g.SetScroll(true);
            //g.SetAutoWidth( true ); //  will force the grid to fit the width of the parent element
            g.SetWidth(CommonConstants.GridStandardWidth);
            g.SetMultiSelect(true);
            g.SetUrl(VirtualPathUtility.ToAbsolute("~/Sample/GridDataSample/"));
            g.SetRowNum(totRecs);               //  Sets the number of rows displayed initially
            g.OnSelectAll("pat.sampleClaimList_RowSelected()");
            g.OnSelectRow("pat.sampleClaimList_RowSelected()");
            g.OnLoadComplete("pat.sampleClaimList_LoadEvent();");
            return(g);
        }
예제 #25
0
        private static IEnumerable <IRenderable> GetArguments(CommandInfo?command)
        {
            var arguments = HelpArgument.Get(command);

            if (arguments.Count == 0)
            {
                return(Array.Empty <IRenderable>());
            }

            var result = new List <IRenderable>
            {
                new Markup("[yellow]ARGUMENTS:[/]"),
                new Markup("\n"),
            };

            var grid = new Grid();

            grid.AddColumn(new GridColumn {
                Padding = new Padding(4, 4), NoWrap = true
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(0, 0)
            });

            foreach (var argument in arguments)
            {
                if (argument.Required)
                {
                    grid.AddRow(
                        $"[silver]<{argument.Name.SafeMarkup()}>[/]",
                        argument.Description?.TrimEnd('.') ?? string.Empty);
                }
                else
                {
                    grid.AddRow(
                        $"[grey][[{argument.Name.SafeMarkup()}]][/]",
                        argument.Description?.TrimEnd('.') ?? string.Empty);
                }
            }

            grid.AddEmptyRow();
            result.Add(grid);

            return(result);
        }
예제 #26
0
 public static Grid Column(this Grid grid, string columnName, int width, string columnLabel, object columnProperties = null)
 {
     if (grid == null)
     {
         throw new ArgumentNullException("grid");
     }
     grid.AddColumn(Column(columnName, width, columnLabel, columnProperties));
     return(grid);
 }
예제 #27
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));
        }
예제 #28
0
        private static IEnumerable <IRenderable> GetArguments(CommandInfo?command)
        {
            var arguments = HelpArgument.Get(command);

            if (arguments.Count == 0)
            {
                return(Array.Empty <IRenderable>());
            }

            var result = new List <IRenderable>
            {
                new Markup(Environment.NewLine),
                new Markup("[yellow]ARGUMENTS:[/]"),
                new Markup(Environment.NewLine),
            };

            var grid = new Grid();

            grid.AddColumn(new GridColumn {
                Padding = new Padding(4, 4), NoWrap = true
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(0, 0)
            });

            foreach (var argument in arguments.Where(x => x.Required).OrderBy(x => x.Position))
            {
                grid.AddRow(
                    $"[silver]<{argument.Name.EscapeMarkup()}>[/]",
                    argument.Description?.TrimEnd('.') ?? " ");
            }

            foreach (var argument in arguments.Where(x => !x.Required).OrderBy(x => x.Position))
            {
                grid.AddRow(
                    $"[grey][[{argument.Name.EscapeMarkup()}]][/]",
                    argument.Description?.TrimEnd('.') ?? " ");
            }

            result.Add(grid);

            return(result);
        }
예제 #29
0
        private void ConfigureModelColumns(Grid grid, GridMetamodel gridModel)
        {
            foreach (var metamodel in gridModel.Columns)
            {
                var metamodelType = metamodel.GetType();
                var configurator  = this.GetConfigurator(metamodelType);
                var column        = configurator.Render(metamodel);

                grid.AddColumn(column);
            }
        }
예제 #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 ");
        }
예제 #31
0
        public Task Should_Render_Grid()
        {
            var console = new PlainConsole(width: 80);
            var grid    = new Grid();

            grid.AddColumn(new GridColumn {
                NoWrap = true
            });
            grid.AddColumn(new GridColumn {
                Padding = new Padding(2, 0, 0, 0)
            });
            grid.AddRow("[bold]Options[/]", string.Empty);
            grid.AddRow("  [blue]-h[/], [blue]--help[/]", "Show command line help.");
            grid.AddRow("  [blue]-c[/], [blue]--configuration[/]", "The configuration to run for.\nThe default for most projects is [green]Debug[/].");

            // When
            console.Render(grid);

            // Then
            return(Verifier.Verify(console.Output));
        }
예제 #32
0
            public static void IsValid(Column column)
            {
                var grid = new Grid("test");
                grid.AddColumn(column);

                JavascriptAssert.IsValid(grid.RenderJavascript());
            }