public void FirstPage_GivenDataRecordsAndPageSize_ReturnsFirstPage() { var sut = new Table(Create10Records(), defaultPageSize: 3); Page nextPage = sut.LastPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages.Last()), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages.First()), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[1]), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[2]), "table's page"); nextPage = sut.LastPage(); Assert.That(nextPage, Is.EqualTo(sut.LastPage()), "table's page"); nextPage = sut.FirstPage(); Assert.That(nextPage, Is.EqualTo(sut.FirstPage()), "table's page"); nextPage = sut.PreviousPage(); Assert.That(nextPage, Is.EqualTo(sut.LastPage()), "table's page"); }
public void Create_GivenDataRecordCountAndPageSize_PageCountAndHeaderWillBeSet(int dataRecordCount, int pageSize, int expectedPageCount) { DataRecord header = new DataRecord(); List<DataRecord> records = new List<DataRecord> { header }; for (int i = 0; i < dataRecordCount; i++) records.Add(new DataRecord()); var sut = new Table(records, pageSize); Assert.That(sut.PageCount, Is.EqualTo(expectedPageCount), "table page count"); Assert.That(sut.Header, Is.EqualTo(header), "table header"); }
public void Show_GivenATableFilledWithDataRecordsFittingOnTwoPages_ShowTableWithAllUserCommands() { Table table = new Table(ThreeDataRecords(), defaultPageSize: 1); var sut = new ConsoleDisplay(); sut.Show(table.NextPage()); sut.PrintUserOptionsFor(table.PageCount); var expectedOutput = "Field1|Field2|Field3|" + NL + "------+------+------+" + NL + "Field1|Field2|Field3|" + NL + CR + NL + ConsoleDisplay.ALL_USER_COMMANDS + CR + NL; Assert.That(displayOutput.ToString(), Is.EqualTo(expectedOutput), "display output"); }
public void Create_GivenDataRecords_InitializePages() { List<DataRecord> dataRecords = new List<DataRecord> { RecordFor(field: "header") }; for (int i = 1; i <= 6; i++) dataRecords.Add(RecordFor(i)); dataRecords.Add(RecordFor(field: "lastPage")); var sut = new Table(dataRecords, defaultPageSize: 3); Assert.That(sut.PageCount, Is.EqualTo(3), "table page count"); Assert.That(sut.Header, Is.EqualTo(RecordFor(field: "header")), "table's page header"); Assert.That(sut.Pages[0], Is.EqualTo(PageContainsRecords(@from: 1, to: 3)), "table's first page"); Assert.That(sut.Pages[1], Is.EqualTo(PageContainsRecords(@from: 4, to: 6)), "table's second page"); Assert.That(sut.Pages[2], Is.EqualTo(ExpectedLastPage()), "table's last page"); }
public void NextPage_GivenDataRecordsAndPageSize_ReturnsNextPage() { var sut = new Table(Create10Records(), defaultPageSize: 3); Page nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[0]), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[1]), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[2]), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[3]), "table's page"); nextPage = sut.NextPage(); Assert.That(nextPage, Is.EqualTo(sut.Pages[0]), "table's page"); }