public void AddingTwoSetsOfHeadersThrowsException() { Assert.Throws(typeof(Exception), delegate() { ConsoleTable.Create().WithHeaders(_headers).WithHeaders(_headers); }); }
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)); }
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)); }
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)); }
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); }); }
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(); }
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 }); }); }