コード例 #1
0
 public void AddingTwoSetsOfHeadersThrowsException()
 {
     Assert.Throws(typeof(Exception),
                   delegate()
     {
         ConsoleTable.Create().WithHeaders(_headers).WithHeaders(_headers);
     });
 }
コード例 #2
0
        public void AddRow_WhereRowIsStringArrayAddsSuccessfully()
        {
            var testRow = new string[] { "1", "2", "3" };

            var table   = ConsoleTable.Create().AddDataRow <string>(testRow);
            var lastRow = table.Data.Last();

            Assert.That(lastRow, Is.EqualTo(testRow));
        }
コード例 #3
0
        public void AddRow_WhereDataImplementsIRowConvertableAddsSuccessfully()
        {
            var rowConvertable = TestRowConvertable.Create();
            var expectedData   = rowConvertable.MapToRow();

            var table   = ConsoleTable.Create().AddDataRow(rowConvertable);
            var lastRow = table.Data.Last();

            Assert.That(lastRow, Is.EqualTo(expectedData));
        }
コード例 #4
0
        public void AddRow_WhereRowIsGenericAddsSuccessfully()
        {
            var testRow     = new int[] { 1, 2, 3 };
            var expectedRow = new string[] { "1", "2", "3" };

            var table   = ConsoleTable.Create().AddDataRow(testRow);
            var lastRow = table.Data.Last();

            Assert.That(lastRow, Is.EqualTo(expectedRow));
        }
コード例 #5
0
        public void AddingTwoRowsSeparatelyWithDifferingNumbersOfColumnsThrowsException()
        {
            var rowOne = new string[] { "One", "Two", "Three" };
            var rowTwo = new string[] { "Four", "Five" };

            Assert.Throws(typeof(Exception),
                          delegate()
            {
                ConsoleTable.Create().AddDataRow(rowOne).AddDataRow(rowTwo);
            });
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var headers = new string[] { "C1", "C2", "C3" };
            var data    = new List <string[]>()
            {
                new string[] { "Mark Ramprakash", "40", "Some house" },
                new string[] { "Kumar Sangakkarra", "39", "Another house" },
                new string[] { "Moeen Ali", "33", "A house" },
            };

            var data2 = new List <object[]>()
            {
                new object[] { 111, "Hi", 12.00 },
                new object[] { 444, 555, 6666 },
                new object[] { 777, 888, 999 }
            };

            var myObjOne   = new MyObject(1, 2, 3);
            var myObjTwo   = new MyObject(4, 5, 6);
            var myObjThree = new MyObject(7, 8, 9);

            var objectt = new object[] { "12", 12, 12.00 };

            var objectData = new IRowConvertable[] { myObjOne, myObjThree, myObjTwo };

            var config = TableConfiguration.Create()
                         .WithHeaderDivider()
                         .WithColumnBorders()
                         .WithRowNumbers()
                         .WithRowBorders()
                         .WithColumnSpacing(9);

            ConsoleTable.Create()
            .WithHeaders(headers)
            .WithData(data2)
            .AddDataRow(myObjTwo)
            .AddDataRow <int>(new int[] { 1, 2, 500000001, 4 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000003 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500003465 })
            .AddDataRow <int>(new int[] { 1, 2, 500006456 })
            .AddDataRow <int>(new int[] { 1, 2, 500000345 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow(objectt)
            .WithConfiguration(config)
            .PrintTable();
        }
コード例 #7
0
        public void AddingDataWithDifferentNumberOfColumnsThrowsException()
        {
            var rowOne = new string[] { "One", "Two", "Three" };
            var rowTwo = new string[] { "Four", "Five" };

            Assert.Throws(typeof(Exception),
                          delegate()
            {
                ConsoleTable.Create().WithData(new List <string[]>()
                {
                    rowOne, rowTwo
                });
            });
        }