public void Search_BeforeSearchFivePagesOfPackagesShownAndSearchReturnsTwoPages_TwoPagesShownAfterSearch() { CreateViewModel(); viewModel.IsSearchable = true; viewModel.PageSize = 2; viewModel.MaximumSelectablePages = 5; viewModel.AddSixFakePackages(); viewModel.FakePackages.Add(new FakePackage("SearchedForId1")); viewModel.FakePackages.Add(new FakePackage("SearchedForId2")); viewModel.FakePackages.Add(new FakePackage("SearchedForId3")); viewModel.ReadPackages(); CompleteReadPackagesTask(); ObservableCollection <Page> pages = viewModel.Pages; ClearReadPackagesTasks(); viewModel.SearchTerms = "SearchedForId"; viewModel.Search(); CompleteReadPackagesTask(); var expectedPages = new Page[] { new Page() { Number = 1, IsSelected = true }, new Page() { Number = 2 } }; PageCollectionAssert.AreEqual(expectedPages, pages); }
public void Pages_OneHundredItemsAndPageSizeIsTenAndSelectablePagesIsFiveWithPageNineSelected_PagesSixToTenDisplayed() { CreatePages(); pages.PageSize = 10; pages.MaximumSelectablePages = 5; pages.SelectedPageNumber = 9; pages.TotalItems = 100; Page[] expectedPages = new Page[] { new Page() { Number = 6 }, new Page() { Number = 7 }, new Page() { Number = 8 }, new Page() { Number = 9, IsSelected = true }, new Page() { Number = 10 }, }; PageCollectionAssert.AreEqual(expectedPages, pages); }
public void Search_SearchTextChangedAndPackagesWerePagedBeforeSearch_PagesUpdatedAfterFilteringBySearchCriteria() { CreateViewModel(); viewModel.IsSearchable = true; viewModel.PageSize = 2; viewModel.MaximumSelectablePages = 5; viewModel.AddSixFakePackages(); var package = new FakePackage() { Id = "SearchedForId", Description = "Test" }; viewModel.FakePackages.Add(package); viewModel.ReadPackages(); CompleteReadPackagesTask(); ObservableCollection <Page> pages = viewModel.Pages; ClearReadPackagesTasks(); viewModel.SearchTerms = "SearchedForId"; viewModel.Search(); CompleteReadPackagesTask(); var expectedPages = new Page[] { new Page() { Number = 1, IsSelected = true } }; PageCollectionAssert.AreEqual(expectedPages, pages); }
public void Pages_SelectedPageNumberChanged_PagesRecalculatedBasedOnNewSelectedPage() { CreateViewModel(); viewModel.PageSize = 3; viewModel.SelectedPageNumber = 1; viewModel.AddSixFakePackages(); viewModel.ReadPackages(); CompleteReadPackagesTask(); ClearReadPackagesTasks(); var oldPages = viewModel.Pages; viewModel.SelectedPageNumber = 2; CompleteReadPackagesTask(); var newPages = viewModel.Pages; Page[] expectedPages = new Page[] { new Page() { Number = 1 }, new Page() { Number = 2, IsSelected = true } }; PageCollectionAssert.AreEqual(expectedPages, newPages); }
public void Pages_TenPackagesSelectedPageNumberIsFiveAndPageSizeIsTwoAndMaximumSelectablePagesIsThree_ReturnsPagesThreeAndFourAndFive() { CreateViewModel(); viewModel.PageSize = 2; viewModel.AddTenFakePackages(); viewModel.ReadPackages(); CompleteReadPackagesTask(); viewModel.SelectedPageNumber = 5; viewModel.MaximumSelectablePages = 3; Page[] expectedPages = new Page[] { new Page() { Number = 3 }, new Page() { Number = 4 }, new Page() { Number = 5, IsSelected = true } }; var actualPages = viewModel.Pages; PageCollectionAssert.AreEqual(expectedPages, actualPages); }
public void Pages_SixPackagesSelectedPageNumberIsThreeAndPageSizeIsTwoAndMaximumSelectablePagesIsTwo_ReturnsPagesTwoAndThreeWithPageThreeSelected() { CreateViewModel(); viewModel.PageSize = 2; viewModel.AddSixFakePackages(); viewModel.ReadPackages(); CompleteReadPackagesTask(); viewModel.SelectedPageNumber = 3; viewModel.MaximumSelectablePages = 2; Page[] expectedPages = new Page[] { new Page() { Number = 2 }, new Page() { Number = 3, IsSelected = true } }; var actualPages = viewModel.Pages; PageCollectionAssert.AreEqual(expectedPages, actualPages); }
public void Pages_SixPackagesSelectedPageNumberIsOneAndPageSizeIsFiveGetPagesTwice_ReturnsTwoPagesWithFirstOneSelected() { CreateViewModel(); viewModel.PageSize = 5; viewModel.AddSixFakePackages(); viewModel.ReadPackages(); CompleteReadPackagesTask(); viewModel.SelectedPageNumber = 1; Page[] expectedPages = new Page[] { new Page() { Number = 1, IsSelected = true }, new Page() { Number = 2 } }; var actualPages = viewModel.Pages; actualPages = viewModel.Pages; PageCollectionAssert.AreEqual(expectedPages, actualPages); }
public void Pages_PageSizeChanged_PagesUpdatedAfterChange() { CreatePages(); pages.PageSize = 2; pages.SelectedPageNumber = 1; pages.TotalItems = 2; pages.PageSize = 1; Page[] expectedPages = new Page[] { new Page() { Number = 1, IsSelected = true }, new Page() { Number = 2 } }; PageCollectionAssert.AreEqual(expectedPages, pages); }