private List <int> Generate() { Brochure brochure = new Brochure((int)nudAllPages.Value, (int)nudRows.Value, (int)nudColumns.Value, chkPageWithSingleCard.Checked); return(brochure.GetPrintingPageNumbers()); }
private void checkPages(int pages, int rows, int columns, int[] expected, bool fillWithSingleCard) { Brochure brochure; List <int> actual; brochure = new Brochure(pages, rows, columns, fillWithSingleCard); actual = brochure.GetPrintingPageNumbers(); if (expected != null) { CollectionAssert.AreEqual(expected, actual, "Page number are invalid."); } // Checks whether all page numbers were used and whether page index // is not out of bound. int maxPages = pages; if (pages % 4 > 0) { maxPages = pages + 4 - pages % 4; } bool[] presence = new bool[maxPages]; int distinctPages = 0; for (int i = 0; i < actual.Count; i++) { int pageNum = actual[i]; Assert.IsTrue(pageNum > 0 && pageNum <= maxPages + 1, "Page number is out of bound."); int pageIndex = pageNum - 1; if (pageIndex < maxPages) { if (!presence[pageIndex]) { distinctPages++; } presence[pageIndex] = true; }// In other case page index indicates empty (dummy) page. } Assert.AreEqual(distinctPages, maxPages, "Incorrect number of distinct pages."); }