public void Case_06()
        {
            var grid = new GridDefinition
            {
                RowDefinitions = new List <RowDefinition>
                {
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    }
                },
                ColumnDefinitions = new List <ColumnDefinition>
                {
                    new ColumnDefinition {
                        WidthType = WidthType.Star, Width = 1
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Fixed, Width = 8
                    }
                }
            };

            grid
            .AddCell("Produto", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Valor", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Total", horizontalAlign: HorizontalAlign.Center);

            grid
            .AddCell("Refeição", horizontalAlign: HorizontalAlign.Right, verticalAlign: VerticalAlign.Middle)
            .AddCell("R$ 44,90")
            .AddCell("0,000 kg")
            .AddCell("R$ 167.008,89");

            grid
            .AddCell("Refrigerantes")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell("Sucos")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            var gridRender = new GridRender(grid);

            var actual = gridRender.Render(57);

            var expected =
                "+----------------------------+--------+--------+--------+" + Environment.NewLine +
                "|          Produto           | Valor  |  Qtd.  | Total  |" + Environment.NewLine +
                "+----------------------------+--------+--------+--------+" + Environment.NewLine +
                "|                            |R$ 44,90|0,000 kg|R$      |" + Environment.NewLine +
                "|                    Refeição|        |        |167.008,|" + Environment.NewLine +
                "|                            |        |        |89      |" + Environment.NewLine +
                "+----------------------------+--------+--------+--------+" + Environment.NewLine +
                "|Refrigerantes               |        |        |        |" + Environment.NewLine +
                "+----------------------------+--------+--------+--------+" + Environment.NewLine +
                "|Sucos                       |        |        |        |" + Environment.NewLine +
                "+----------------------------+--------+--------+--------+" + Environment.NewLine +
                "|                            |        |        |        |" + Environment.NewLine +
                "+----------------------------+--------+--------+--------+";

            Assert.AreEqual(expected, actual);
        }
        public void Case_01()
        {
            var grid = new GridDefinition
            {
                RowDefinitions = new List <RowDefinition>
                {
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    }
                },
                ColumnDefinitions = new List <ColumnDefinition>
                {
                    new ColumnDefinition {
                        WidthType = WidthType.Star, Width = 1
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    }
                }
            };

            grid
            .AddCell("Produto", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Valor", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Total", horizontalAlign: HorizontalAlign.Center);

            grid
            .AddCell("Refeição")
            .AddCell("R$ 44,90")
            .AddCell("0,000 kg")
            .AddCell("R$ 8,89");

            grid
            .AddCell("Refrigerantes")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell("Sucos")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            var gridRender = new GridRender(grid);

            gridRender.AddStyle <WhiteSpaceVerticalBorderStyle>();

            var actual = gridRender.Render(57);

            var expected =
                "            Produto             Valor     Qtd.    Total  " + Environment.NewLine +
                " Refeição                      R$ 44,90 0,000 kg R$ 8,89 " + Environment.NewLine +
                " Refrigerantes                                           " + Environment.NewLine +
                " Sucos                                                   " + Environment.NewLine +
                "                                                         ";


            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void Case_01()
        {
            var grid = new GridDefinition
            {
                RowDefinitions = new List <RowDefinition>
                {
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    },
                    new RowDefinition {
                        HeightType = HeightType.Auto
                    }
                },
                ColumnDefinitions = new List <ColumnDefinition>
                {
                    new ColumnDefinition {
                        WidthType = WidthType.Star, Width = 1
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    },
                    new ColumnDefinition {
                        WidthType = WidthType.Auto
                    }
                }
            };

            grid
            .AddCell("Produto", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Valor", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center)
            .AddCell("Total", horizontalAlign: HorizontalAlign.Center);

            grid
            .AddCell("Refeição")
            .AddCell("R$ 44,90")
            .AddCell("0,000 kg")
            .AddCell("R$ 8,89");

            grid
            .AddCell("Refrigerantes")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell("Sucos")
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            grid
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty)
            .AddCell(string.Empty);

            var gridRender = new GridRender(grid);

            gridRender.AddStyle <InsideBordersStyle>();
            gridRender.AddStyle <HeaderBorderStyle>();

            var actual = gridRender.Render(57);

            var expected =
                "+-----------------------------+--------+--------+-------+" + Environment.NewLine +
                "|           Produto           | Valor  |  Qtd.  | Total |" + Environment.NewLine +
                "+-----------------------------+--------+--------+-------+" + Environment.NewLine +
                "Refeição                      |R$ 44,90|0,000 kg|R$ 8,89 " + Environment.NewLine +
                "------------------------------+--------+--------+--------" + Environment.NewLine +
                "Refrigerantes                 |        |        |        " + Environment.NewLine +
                "------------------------------+--------+--------+--------" + Environment.NewLine +
                "Sucos                         |        |        |        " + Environment.NewLine +
                "------------------------------+--------+--------+--------" + Environment.NewLine +
                "                              |        |        |        ";

            Assert.AreEqual(expected, actual);
        }