public void AllValues_Should_YieldAllValues() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var column1 = Model.AllValuesForColumn(0, model); var column2 = Model.AllValuesForColumn(1, model); CollectionAssert.AreEqual(column1, new [] { "Foo","1", "1111" }); CollectionAssert.AreEqual(column2, new [] { "Bar","2", "2222" }); }
public void AllValues_Should_YieldAllValues() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var column1 = Model.AllValuesForColumn(0, model); var column2 = Model.AllValuesForColumn(1, model); CollectionAssert.AreEqual(column1, new [] { "Foo", "1", "1111" }); CollectionAssert.AreEqual(column2, new [] { "Bar", "2", "2222" }); }
public void CanRenderSimpleTable() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var output = new TableFormatter().Format(model); Assert.AreEqual(@"Foo |Bar | ----+----+ 1 |2 | 1111|2222| ", output); }
public void CanRenderSimpleTable() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var output = new TableFormatter().Format(model); Assert.AreEqual(@"Foo |Bar | ----+----+ 1 |2 | 1111|2222| ", output); }
public void CanRenderPagedTable_Page1() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var page1 = new PagedModel(model, 1, 1); var output = new TableFormatter().Format(page1); Assert.AreEqual(@"Foo |Bar | ----+----+ 1111|2222| ", output); }
public void CanRenderPagedTable_Page1() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); var page1 = new PagedModel(model, 1, 1); var output = new TableFormatter().Format(page1); Assert.AreEqual(@"Foo |Bar | ----+----+ 1111|2222| ", output); }
public void ShouldYieldNumberOfPages() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); var paged = new PagedModel(model, 0, 2); Assert.AreEqual(3, paged.MaxPageIndex); }
public void ShouldYieldNumberOfPages() { var model = new Model(); model.SetHeader(new[] { "Foo", "Bar" }); model.AddRow(new[] { "1", "2" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); model.AddRow(new[] { "1111", "2222" }); var paged = new PagedModel(model, 0, 2); Assert.AreEqual(3, paged.MaxPageIndex); }
public Model Read(Stream input) { var result = new Model(); using (var reader = new StreamReader(input)) { Action <IEnumerable <string> > addRow = items => result.AddRow(items); Action <IEnumerable <string> > add = items => result.SetHeader(items); string line; while ((line = reader.ReadLine()) != null) { var items = line.Split(';'); add(items); add = addRow; } } return(result); }
public Model Read(Stream input) { var result = new Model(); using (var reader = new StreamReader(input)) { Action<IEnumerable<string>> addRow = items => result.AddRow(items); Action<IEnumerable<string>> add = items => result.SetHeader(items); string line; while ((line = reader.ReadLine()) != null) { var items = line.Split(';'); add(items); add = addRow; } } return result; }