public void Items_WhenNull_ReturnEmptyAndNotNull()
        {
            var dummy = BuildPageCounter.AValidOne().Please();
            var sut   = new PagedViewModel <int>(dummy, null);

            sut.ItemsInThePage.Should().BeEmpty().And.NotBeNull();
        }
        public void Counter_ByDefault_ReturnsCounter(IEnumerable <int> dummy)
        {
            var counter = BuildPageCounter.AValidOne().Please();
            var sut     = new PagedViewModel <int>(counter, dummy.AsQueryable());

            sut.Counter.Should().Be(counter);
        }
        public void PageNumber_WhenSmallerThan1_Returns1()
        {
            var sut = BuildPageCounter.AValidOne()
                      .WithPageNumber(0)
                      .Please();

            sut.Number.Should().Be(1);
        }
        public void PageNumber_When0_AndPageCountIs0_Returns1()
        {
            var sut = BuildPageCounter.AValidOne()
                      .WithPageNumber(0)
                      .WithTotalItemCount(0)
                      .Please();

            sut.Number.Should().Be(1);
        }
        public void TotalItemCount_CanBeSmallerThanSize(byte pageSize)
        {
            var    totalItemCount = (uint)pageSize - 10;
            Action act            = () => BuildPageCounter.AValidOne()
                                    .WithPageSize(pageSize)
                                    .WithTotalItemCount(totalItemCount)
                                    .Please();

            act.Should().NotThrow <Exception>();
        }
        public void HasNext_WhenPageNumberIsTotalPageCount_RetunsFalse(
            byte number, byte size, byte totalItemCount)
        {
            var sut = BuildPageCounter.AValidOne()
                      .WithPageNumber(number)
                      .WithPageSize(size)
                      .WithTotalItemCount(totalItemCount)
                      .Please();

            sut.HasNext.Should().BeFalse();
        }
        public void PageNumber_WhenBiggerThanTotalPageCount_ReturnsTotalPageCount(
            byte number, byte size, byte totalItemCount)
        {
            var sut = BuildPageCounter.AValidOne()
                      .WithPageNumber(number)
                      .WithPageSize(size)
                      .WithTotalItemCount(totalItemCount)
                      .Please();

            sut.Number.Should().Be(sut.TotalPageCount);
        }
        public void TotalPageCount_Allways_ReturnsTotalPageCount(
            byte pageSize, uint totalRecordCount, uint expectedTotalPageCount)
        {
            var sut = BuildPageCounter.AValidOne()
                      .WithPageSize(pageSize)
                      .WithTotalItemCount(totalRecordCount)
                      .Please();

            sut.TotalPageCount.Should().Be(expectedTotalPageCount);

            //TODO: refactor to property-based test:
            (sut.TotalPageCount * pageSize).Should().BeCloseTo(sut.TotalItemCount, 10);
        }
        [Property]//Mathematical test:
        public void Items_WhenSomeItemsAreIncludedInRequestedPage_ReturnsPagedItems(
            PositiveInt pageNumber, PositiveInt pageSize, NonEmptyArray <int> randomArray)
        {
            //TODO: move this to the arbitrary generators:
            var allItems = randomArray.Item.Select((item, i) => (Item: item, Index: i + 1))
                           .AsQueryable();

            var pageCounter = BuildPageCounter.AValidOne()
                              .WithPageNumber((uint)pageNumber.Item)
                              .WithPageSize((byte)pageSize.Item)
                              .Please();

            var sut = new PagedViewModel <(int Item, int Index)>(pageCounter, allItems);

            if (sut.ItemsInThePage.Any())//TODO: remove this if statement by identifying the corresponding equivalent class arbitraries
            {
                var expected = (byte)((sut.ItemsInThePage.First().Index / pageCounter.Size) + 1);
                pageCounter.Number.Should().Be(expected);
            }
        }
        public void Size_ByDefault_ReturnsPageSize(byte expectedSize)
        {
            var result = BuildPageCounter.AValidOne().WithPageSize(expectedSize).Please();

            result.Size.Should().Be(expectedSize);
        }
        public void Size_When0_Returns5()
        {
            var sut = BuildPageCounter.AValidOne().WithPageSize(0).Please();

            sut.Size.Should().Be(5);
        }
        public void HasPrevious_WhenPageNumberIsBiggerThan1_ReturnsTrue(byte pageNumber)
        {
            var sut = BuildPageCounter.AValidOne().WithPageNumber(pageNumber).Please();

            sut.HasPrevious.Should().BeTrue();
        }
        public void HasPrevious_WhenPageNumberIs1_ReturnsFalse()
        {
            var sut = BuildPageCounter.AValidOne().WithPageNumber(1).Please();

            sut.HasPrevious.Should().BeFalse();
        }