public void findPage() { int pageSize = 5; //------------- 第1页 --------------- int current = 1; CurrentRequest.setCurrentPage(current); DataPage <TBoard> list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(pageSize, list.Results.Count); //------------- 第2页 --------------- current = 2; CurrentRequest.setCurrentPage(current); list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(pageSize, list.Results.Count); //------------- 第3页 --------------- current = 3; CurrentRequest.setCurrentPage(current); list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(2, list.Results.Count); }
public void findPage() { int pageSize = 5; //------------- 第1页 --------------- int current = 1; CurrentRequest.setCurrentPage(current); DataPage <TBoard> list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(pageSize, list.Results.Count); //------------- 第2页 --------------- current = 2; CurrentRequest.setCurrentPage(current); list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(pageSize, list.Results.Count); //------------- 第3页 --------------- current = 3; CurrentRequest.setCurrentPage(current); list = TBoard.findPage("Id>0", pageSize); Assert.AreEqual(current, list.Current); Assert.AreEqual(12, list.RecordCount); Assert.AreEqual(3, list.PageCount); Assert.AreEqual(pageSize, list.Size); Assert.AreEqual(2, list.Results.Count); //------------- 第n页 --------------- for (int i = 0; i < 100; i++) { TBoard board = new TBoard(); board.Name = "board_pageTest_" + i; board.insert(); } current = 2; CurrentRequest.setCurrentPage(current); list = TBoard.findPage("Id>0 order by Id asc", 10); Assert.AreEqual(current, list.Current); Assert.AreEqual(112, list.RecordCount); Assert.AreEqual(12, list.PageCount); Assert.AreEqual(10, list.Results.Count); String ids = ""; foreach (TBoard bd in list.Results) { ids += bd.Id + ", " + bd.Name + Environment.NewLine; } Console.WriteLine(ids); String bar = strUtil.ParseHtml(list.PageBar).Replace(" ", ","); Console.WriteLine(bar); }