public ActionResult HistoryNextPage(HistoryPageMetadata metadata) { IEnumerable <HistoryModel> model = UserService.History.Get(metadata.HistoryType); Pageable <HistoryModel> data = model.ToHistoryModelList(new Pageable <HistoryModel>(metadata)); return(View(data)); }
public void HistoryNextPage() { var results = new[] { new HistoryModel { DateAccessed = DateTime.Now, IsPinned = false, Values = new RouteValueDictionary { { "id", "123" } }, DisplayName = "Foo", HistoryType = HistoryType.JobSeeker }, new HistoryModel { DateAccessed = DateTime.Now, IsPinned = false, Values = new RouteValueDictionary { { "id", "456" } }, DisplayName = "Bar", HistoryType = HistoryType.JobSeeker } }; var metadata = new HistoryPageMetadata { HistoryType = HistoryType.JobSeeker, PageNumber = 1, PageSize = 1, Total = 2 }; var getResults = new Pageable <HistoryModel>(metadata); getResults.AddRange(results); //mockMappingEngine.Setup(m => m.Map<IEnumerable<HistoryModel>, IPageable<HistoryModel>>(It.IsAny<IEnumerable<HistoryModel>>(), It.IsAny<IPageable<HistoryModel>>())).Returns(getResults); var controller = SystemUnderTest(); var result = controller.HistoryNextPage(metadata); ViewResult viewResult = result as ViewResult; IPageable <HistoryModel> model = viewResult.Model as IPageable <HistoryModel>; Assert.IsNotNull(viewResult, "ViewResult should not be null."); Assert.IsNotNull(model, "model should not be null."); Assert.IsTrue(model.Count() == 2); Assert.IsTrue(model.Metadata is HistoryPageMetadata); Assert.AreEqual(((HistoryPageMetadata)model.Metadata).HistoryType, HistoryType.JobSeeker); Assert.AreEqual(model.Metadata.PageNumber, 1); Assert.AreEqual(model.Metadata.PageSize, 1); Assert.AreEqual(model.Metadata.Total, 2); }