public async Task LoadPageAsync_should_return_empty_first_page_for_empty_data()
            {
                var theCase = new EntityListCase();

                var page = await theCase.EntityList.Paging(3).LoadPageAsync(0);

                page.Should().BeEmpty();
            }
            public void Paging_should_fail_when_given_zero_page_size()
            {
                var theCase = new EntityListCase();

                Action action = () => theCase.EntityList.Paging(0);

                action.Should().Throw <ArgumentException>();
            }
            public async Task LoadAllAsync_should_return_empty_list_when_there_is_no_data()
            {
                var theCase = new EntityListCase();

                var allItems = await theCase.EntityList.SliceBy(3).LoadAllAsync();

                allItems.Should().BeEmpty();
                theCase.DataLoadCount.Should().Be(1);
            }
            public void Skip_should_fail_when_given_negative_skip_elements()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                Action action = () => theCase.EntityList.SliceBy(10).Skip(-1);

                action.Should().Throw <ArgumentException>();
            }
            public async Task LoadPageAsync_should_fail_when_given_negative_page_index()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                Func <Task> action = async() => await theCase.EntityList.Paging(3).LoadPageAsync(-1);

                await action.Should().ThrowAsync <ArgumentException>();
            }
            public async Task LoadSliceAsync_should_return_empty_slice_when_there_is_no_data()
            {
                var theCase = new EntityListCase();

                var slice = await theCase.EntityList.SliceBy(10).LoadSliceAsync();

                slice.Items.Should().BeEmpty();
                slice.HasNextSlice.Should().BeFalse();
                slice.TotalItems.Should().Be(0);
            }
            public async Task LoadSliceAsync_should_return_empty_slice_when_given_empty_slice_size()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                var slice = await theCase.EntityList.SliceBy(0).LoadSliceAsync();

                slice.Items.Should().BeEmpty();
                slice.HasNextSlice.Should().BeFalse();
                slice.TotalItems.Should().Be(100);
            }
            public async Task LoadPageAsync_should_load_intermediate_page()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                var expectedPageData = theCase.GetExpectedPageData(10, 3);

                var page = await theCase.EntityList.Paging(3).LoadPageAsync(10);

                page.Should().BeEquivalentTo(expectedPageData);
                page.TotalPages.Should().Be(34);
            }
            public async Task LoadPageAsync_should_return_non_existent_page_if_page_index_is_too_big()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                const int lastPageIndex = 33;

                var page = await theCase.EntityList.Paging(3).LoadPageAsync(lastPageIndex + 1);

                page.Should().BeEmpty();
                page.CurrentPage.Should().Be(34);
                page.TotalPages.Should().Be(34);
            }
Ejemplo n.º 10
0
            public async Task LoadPageAsync_should_load_last_page()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                const int lastPageIndex    = 33;
                var       expectedPageData = theCase.GetExpectedPageData(lastPageIndex, 3);

                var page = await theCase.EntityList.Paging(3).LoadPageAsync(lastPageIndex);

                page.Should().BeEquivalentTo(expectedPageData);
                page.TotalPages.Should().Be(34);
            }
Ejemplo n.º 11
0
            public async Task LoadAllAsync_should_load_all_items_by_slices()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);
                const int sliceCount = 34;

                var expectedItems = theCase.AllData;

                var allItems = await theCase.EntityList.SliceBy(3).LoadAllAsync();

                allItems.Should().BeEquivalentTo(expectedItems);
                theCase.DataLoadCount.Should().Be(sliceCount);
            }
Ejemplo n.º 12
0
            public async Task LoadSliceAsync_should_return_last_slice()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                var expectedSliceData = theCase.GetExpectedSliceData(91, 9);

                var slice = await theCase.EntityList.SliceBy(10).Skip(91).LoadSliceAsync();

                slice.Items.Should().BeEquivalentTo(expectedSliceData);
                slice.HasNextSlice.Should().BeFalse();
                slice.TotalItems.Should().Be(100);
            }
Ejemplo n.º 13
0
            public async Task LoadSliceAsync_should_return_first_slice_by_specifying_zero_skipped_items()
            {
                var theCase = new EntityListCase()
                              .MakeDataAvailable(100);

                var expectedSliceData = theCase.GetExpectedSliceData(0, 10);

                var slice = await theCase.EntityList.SliceBy(10).Skip(0).LoadSliceAsync();

                slice.Items.Should().BeEquivalentTo(expectedSliceData);
                slice.HasNextSlice.Should().BeTrue();
                slice.TotalItems.Should().Be(100);
            }