コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }