示例#1
0
 private void RenderAllLines(CellX cellX, Size size)
 {
     for (int i = 0; i < size.Height; i++)
     {
         cellX.RenderNextLine(tablePrinter.Object, size);
     }
 }
        public void HavingARowContainingACellAndBorder_WhenCalculatingLayout_ThenRowSizeIsEqualToTheCellSizePlusBorder()
        {
            CellX cellX1 = new CellX
            {
                Content = "value 1"
            };

            cellX1.CalculateLayout();
            DataGridBorderX dataGridBorderX = new DataGridBorderX
            {
                Template = BorderTemplate.PlusMinusBorderTemplate
            };
            RowX rowX = new RowX
            {
                Cells = new List <CellX>
                {
                    cellX1
                },
                Border = dataGridBorderX
            };

            rowX.CalculateLayout();

            Size expected = new Size(9, 1);

            Assert.AreEqual(expected, rowX.Size);
        }
示例#3
0
        public void HavingContentShorterThanCellWidth_WhenRendered_LineIsFilledWithSpaces()
        {
            CellX cell = new CellX
            {
                Content = "text"
            };

            RenderAllLines(cell, new Size(10, 1));

            Assert.That(renderingOutput, Is.EqualTo(new[] { "text      " }));
        }
示例#4
0
        public void HavingPaddingLeftAndContentShorterThanCellWidth_WhenRendered_LineContainsPaddingLeft()
        {
            CellX cell = new CellX
            {
                Content     = "text",
                PaddingLeft = 2
            };

            RenderAllLines(cell, new Size(10, 1));

            Assert.That(renderingOutput, Is.EqualTo(new[] { "  text    " }));
        }
示例#5
0
        public void HavingContentLongerThanCellWidth_WhenRendered_ThenLineIsNotTrimmed()
        {
            CellX cell = new CellX
            {
                Content = "some long text"
            };

            RenderAllLines(cell, new Size(10, 1));

            Assert.That(renderingOutput, Is.EqualTo(new List <string> {
                "some long text"
            }));
        }
示例#6
0
        public void HavingContentWithMoreLinesThanCellHeight_WhenRendered_ThenOnlyTheRequiredLinesAreRendered()
        {
            CellX cell = new CellX
            {
                Content = new MultilineText(new[] { "line1", "line2", "line3" }),
            };

            RenderAllLines(cell, new Size(10, 2));

            Assert.That(renderingOutput, Is.EqualTo(new List <string>
            {
                "line1     ",
                "line2     "
            }));
        }
示例#7
0
        public void HavingContentWithLessLinesThanCellHeight_WhenRendered_ThenEmptyLinesAreAdded()
        {
            CellX cell = new CellX
            {
                Content = "text"
            };

            RenderAllLines(cell, new Size(10, 2));

            Assert.That(renderingOutput, Is.EqualTo(new List <string>
            {
                "text      ",
                "          "
            }));
        }
示例#8
0
        public void Test_SubGridTree_CalculateIndexOfCellContainingPosition_FailOutsideOfOrdinateRange()
        {
            ISubGridTree tree = new SubGridTree(SubGridTreeConsts.SubGridTreeLevels, 1.0, new SubGridFactory <NodeSubGrid, LeafSubGrid>());

            Assert.False(tree.CalculateIndexOfCellContainingPosition(tree.MaxOrdinate + 1, tree.MaxOrdinate + 1, out int CellX, out int CellY));
            CellX.Should().Be(int.MaxValue);
            CellY.Should().Be(int.MaxValue);

            Assert.False(tree.CalculateIndexOfCellContainingPosition(-tree.MaxOrdinate - 1, -tree.MaxOrdinate - 1, out CellX, out CellY));
            CellX.Should().Be(int.MaxValue);
            CellY.Should().Be(int.MaxValue);

            Assert.False(tree.CalculateIndexOfCellContainingPosition(tree.MaxOrdinate + 1, -tree.MaxOrdinate - 1, out CellX, out CellY));
            CellX.Should().Be(int.MaxValue);
            CellY.Should().Be(int.MaxValue);

            Assert.False(tree.CalculateIndexOfCellContainingPosition(-tree.MaxOrdinate - 1, tree.MaxOrdinate + 1, out CellX, out CellY));
            CellX.Should().Be(int.MaxValue);
            CellY.Should().Be(int.MaxValue);
        }
        public void HavingARowContainingACellAndNoBorder_WhenCalculatingLayout_ThenRowSizeIsEqualToTheCellSize()
        {
            CellX cellX1 = new CellX
            {
                Content = "value 1"
            };

            cellX1.CalculateLayout();
            RowX rowX = new RowX
            {
                Cells = new List <CellX>
                {
                    cellX1
                }
            };

            rowX.CalculateLayout();

            Size expected = new Size(7, 1);

            Assert.AreEqual(expected, rowX.Size);
        }
示例#10
0
 set => SetCell(CellX, CellY, value);
示例#11
0
 get => GetCell(CellX, CellY);
示例#12
0
 public override string ToString()
 {
     return(Index.ToString() + " (" + CellX.ToString() + ", " + CellY.ToString() + ") - " +
            (Paths1?.Length ?? 0).ToString() + ", " + (Paths2?.Length ?? 0).ToString() + " - (" +
            CellMin.ToString() + " - " + CellMax.ToString() + ")");
 }