Пример #1
0
        public ConsoleTableSettings(TableSymbols tableSymbols = null, bool sameRowLength = false)
        {
            if (tableSymbols == null)
            {
                tableSymbols = new TableSymbols();
            }

            TableSymbols  = tableSymbols;
            SameRowLength = sameRowLength;
        }
Пример #2
0
        public void Test_GetBorderSymbol_Default()
        {
            var tableSymbols = new TableSymbols();

            Assert.AreEqual(tableSymbols.TopRightCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Top));
            Assert.AreEqual(tableSymbols.TopLeftCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Top));
            Assert.AreEqual(tableSymbols.BottomRightCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Bottom));
            Assert.AreEqual(tableSymbols.BottomLeftCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Bottom));
            Assert.AreEqual(tableSymbols.RightRowSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Center));
            Assert.AreEqual(tableSymbols.LeftRowSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Center));
            Assert.AreEqual(tableSymbols.TopColumnSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Top));
            Assert.AreEqual(tableSymbols.BottomColumnSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Bottom));
            Assert.AreEqual(tableSymbols.TableFieldCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Center));
        }
Пример #3
0
        public void Test_Create_Valid()
        {
            var topRightCorner             = 'a';
            var topLeftCorner              = 'b';
            var bottomRightCorner          = 'c';
            var bottomLeftCorner           = 'd';
            var rightRowSeperator          = 'e';
            var leftRowSeperator           = 'f';
            var topColumnSeperator         = 'g';
            var bottomColumnSeperator      = 'h';
            var tableFieldCorner           = 'i';
            var horizontalTableFieldBorder = 'j';
            var verticalTableFieldBorder   = 'k';

            var tableSymbols = new TableSymbols
            {
                TopRightCorner             = topRightCorner,
                TopLeftCorner              = topLeftCorner,
                BottomRightCorner          = bottomRightCorner,
                BottomLeftCorner           = bottomLeftCorner,
                RightRowSeperator          = rightRowSeperator,
                LeftRowSeperator           = leftRowSeperator,
                TopColumnSeperator         = topColumnSeperator,
                BottomColumnSeperator      = bottomColumnSeperator,
                TableFieldCorner           = tableFieldCorner,
                HorizontalTableFieldBorder = horizontalTableFieldBorder,
                VerticalTableFieldBorder   = verticalTableFieldBorder
            };

            var settings = new ConsoleTableSettings(tableSymbols, true);

            Assert.AreEqual(tableSymbols, settings.TableSymbols);
            Assert.AreEqual(topRightCorner, settings.TableSymbols.TopRightCorner);
            Assert.AreEqual(topLeftCorner, settings.TableSymbols.TopLeftCorner);
            Assert.AreEqual(bottomRightCorner, settings.TableSymbols.BottomRightCorner);
            Assert.AreEqual(bottomLeftCorner, settings.TableSymbols.BottomLeftCorner);
            Assert.AreEqual(rightRowSeperator, settings.TableSymbols.RightRowSeperator);
            Assert.AreEqual(leftRowSeperator, settings.TableSymbols.LeftRowSeperator);
            Assert.AreEqual(topColumnSeperator, settings.TableSymbols.TopColumnSeperator);
            Assert.AreEqual(bottomColumnSeperator, settings.TableSymbols.BottomColumnSeperator);
            Assert.AreEqual(tableFieldCorner, settings.TableSymbols.TableFieldCorner);
            Assert.AreEqual(horizontalTableFieldBorder, settings.TableSymbols.HorizontalTableFieldBorder);
            Assert.AreEqual(verticalTableFieldBorder, settings.TableSymbols.VerticalTableFieldBorder);
            Assert.IsTrue(settings.SameRowLength);
        }
Пример #4
0
        public void Test_GetBorderSymbol_Custom_TableSymbols()
        {
            var topRightCorner             = 'a';
            var topLeftCorner              = 'b';
            var bottomRightCorner          = 'c';
            var bottomLeftCorner           = 'd';
            var rightRowSeperator          = 'e';
            var leftRowSeperator           = 'f';
            var topColumnSeperator         = 'g';
            var bottomColumnSeperator      = 'h';
            var tableFieldCorner           = 'i';
            var horizontalTableFieldBorder = 'j';
            var verticalTableFieldBorder   = 'k';

            var tableSymbols = new TableSymbols
            {
                TopRightCorner             = topRightCorner,
                TopLeftCorner              = topLeftCorner,
                BottomRightCorner          = bottomRightCorner,
                BottomLeftCorner           = bottomLeftCorner,
                RightRowSeperator          = rightRowSeperator,
                LeftRowSeperator           = leftRowSeperator,
                TopColumnSeperator         = topColumnSeperator,
                BottomColumnSeperator      = bottomColumnSeperator,
                TableFieldCorner           = tableFieldCorner,
                HorizontalTableFieldBorder = horizontalTableFieldBorder,
                VerticalTableFieldBorder   = verticalTableFieldBorder
            };

            Assert.AreEqual(topRightCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Top));
            Assert.AreEqual(topLeftCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Top));
            Assert.AreEqual(bottomRightCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Bottom));
            Assert.AreEqual(bottomLeftCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Bottom));
            Assert.AreEqual(rightRowSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Right, VerticalBorder.Center));
            Assert.AreEqual(leftRowSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Left, VerticalBorder.Center));
            Assert.AreEqual(topColumnSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Top));
            Assert.AreEqual(bottomColumnSeperator, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Bottom));
            Assert.AreEqual(tableFieldCorner, tableSymbols.GetBorderSymbol(HorizontalBorder.Center, VerticalBorder.Center));
        }
Пример #5
0
        public void Test_TableSymbols()
        {
            var tableSymbols = new TableSymbols
            {
                TopRightCorner             = 'a',
                TopLeftCorner              = 'b',
                BottomRightCorner          = 'c',
                BottomLeftCorner           = 'd',
                RightRowSeperator          = 'e',
                LeftRowSeperator           = 'f',
                TopColumnSeperator         = 'g',
                BottomColumnSeperator      = 'h',
                TableFieldCorner           = 'i',
                HorizontalTableFieldBorder = 'j',
                VerticalTableFieldBorder   = 'k'
            };

            var settings = new ConsoleTableSettings {
                TableSymbols = tableSymbols
            };

            Assert.AreEqual(tableSymbols, settings.TableSymbols);
        }
Пример #6
0
        public void Test_ToDefault()
        {
            var tableSymbols = new TableSymbols
            {
                TopRightCorner             = 'a',
                TopLeftCorner              = 'b',
                BottomRightCorner          = 'c',
                BottomLeftCorner           = 'd',
                RightRowSeperator          = 'e',
                LeftRowSeperator           = 'f',
                TopColumnSeperator         = 'g',
                BottomColumnSeperator      = 'h',
                TableFieldCorner           = 'i',
                HorizontalTableFieldBorder = 'j',
                VerticalTableFieldBorder   = 'k'
            };

            var settings = new ConsoleTableSettings(tableSymbols, true);

            settings.ToDefault();
            var defaultTableSymbols = new TableSymbols();

            Assert.IsNotNull(settings.TableSymbols);
            Assert.AreEqual(defaultTableSymbols.TopRightCorner, settings.TableSymbols.TopRightCorner);
            Assert.AreEqual(defaultTableSymbols.TopLeftCorner, settings.TableSymbols.TopLeftCorner);
            Assert.AreEqual(defaultTableSymbols.BottomRightCorner, settings.TableSymbols.BottomRightCorner);
            Assert.AreEqual(defaultTableSymbols.BottomLeftCorner, settings.TableSymbols.BottomLeftCorner);
            Assert.AreEqual(defaultTableSymbols.RightRowSeperator, settings.TableSymbols.RightRowSeperator);
            Assert.AreEqual(defaultTableSymbols.LeftRowSeperator, settings.TableSymbols.LeftRowSeperator);
            Assert.AreEqual(defaultTableSymbols.TopColumnSeperator, settings.TableSymbols.TopColumnSeperator);
            Assert.AreEqual(defaultTableSymbols.BottomColumnSeperator, settings.TableSymbols.BottomColumnSeperator);
            Assert.AreEqual(defaultTableSymbols.TableFieldCorner, settings.TableSymbols.TableFieldCorner);
            Assert.AreEqual(defaultTableSymbols.HorizontalTableFieldBorder, settings.TableSymbols.HorizontalTableFieldBorder);
            Assert.AreEqual(defaultTableSymbols.VerticalTableFieldBorder, settings.TableSymbols.VerticalTableFieldBorder);
            Assert.IsFalse(settings.SameRowLength);
        }
Пример #7
0
 public void ToDefault()
 {
     SameRowLength = false;
     TableSymbols  = new TableSymbols();
 }