public void PaginateMultiplePageOnLastPageExpectOutModelIsConsistent()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageSize   = 50;
            model.PageNumber = 4;
            PagingParameterOutModel <String> result = paginer.GetPaginationFromFullList(model, CreateItems(210));

            Assert.NotNull(result);
            Assert.False(result.HasNextPage);
            Assert.True(result.HasPreviousPage);
            Assert.True(result.TotalItemsCount == 210);
            Assert.True(result.CurrentPage == 4);
            IEnumerable <String> items = result.PageItems;

            Assert.NotNull(items);
            Assert.NotEmpty(items);
            IEnumerator <String> enumerator = items.GetEnumerator();
            int    i = 200;
            String valueExceptedi = String.Empty;

            while (enumerator.MoveNext())
            {
                valueExceptedi = "Items number " + i.ToString();
                Assert.Equal(valueExceptedi, enumerator.Current);
                i++;
            }
            Assert.True(i == 210);
        }
        public void PaginateEmptyListsReturnSinglePagePaginationWithEmptyResult()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageNumber = 0;
            model.PageSize   = 20;
            List <String> paginerItems = new List <String>();
            PagingParameterOutModel <String> retour = paginer.GetPaginationFromFullList(model, paginerItems);

            Assert.NotNull(retour);
            Assert.True(retour.TotalItemsCount == 0);
            Assert.True(retour.TotalPages == 1);
            Assert.True(retour.PageSize == 20);
            Assert.NotNull(retour.PageItems);
            int itemsCount = 0;
            IEnumerator <String> enumerator = retour.PageItems.GetEnumerator();

            while (enumerator.MoveNext())
            {
                itemsCount++;
            }
            Assert.True(itemsCount == 0);
            Assert.False(retour.HasPreviousPage);
            Assert.False(retour.HasNextPage);
            Assert.True(retour.CurrentPage == 0);
        }
        public void ValidatePaginationInWithEnumerableNullThrowArgumentNullException()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            Assert.Throws <ArgumentNullException>(() => paginer.IsValid(model, null));
        }
        public void ValidatePaginationInPAgeSizeNullThrowInvalidOperationException()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageSize = 0;
            Assert.Throws <InvalidOperationException>(() => paginer.IsValid(model, CreateItems(50)));
        }
        public void PaginateNullListsThrowArgumentNullException()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageNumber = 0;
            model.PageSize   = 20;
            Assert.Throws <ArgumentNullException>(() => paginer.GetPaginationFromFullList(model, null));
        }
        public void ValidatePaginationInFirstPageWithSinglePageEnumerableReturnTrue()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageSize   = 50;
            model.PageNumber = 0;
            Assert.True(paginer.IsValid(model, CreateItems(200)));
        }
        private void ValidatePaginationInWith49ItemsOutOfBoundEnumerableReturnFalse()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageSize   = 50;
            model.PageNumber = 2;
            Assert.False(paginer.IsValid(model, CreateItems(49)));
        }
        public void PaginatePaginationInInvalidThrowAInvalidArgumentException()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageNumber = 5;
            model.PageSize   = 100;
            Assert.Throws <Exception>(() => paginer.GetPaginationFromFullList(model, CreateItems(50)));
        }
        public void PaginatePaginationInWithPageSize0ThrowInvalidOperationException()
        {
            HRPaginer <String>     paginer = new HRPaginer <String>();
            PagingParameterInModel model   = new PagingParameterInModel();

            model.PageNumber = 0;
            model.PageSize   = 0;
            Assert.Throws <InvalidOperationException>(() => paginer.GetPaginationFromFullList(model, CreateItems(50)));
        }
        public void PaginateNullPaginationInThrowArgumentsNullException()
        {
            HRPaginer <String> paginer = new HRPaginer <String>();

            Assert.Throws <ArgumentNullException>(() => paginer.GetPaginationFromFullList(null, PaginationTest.CreateItems(50)));
        }
        public void ValidatePaginationInWithModelNullThrowArgumentNullException()
        {
            HRPaginer <String> paginer = new HRPaginer <String>();

            Assert.Throws <ArgumentNullException>(() => paginer.IsValid(null, CreateItems(50)));
        }