Exemplo n.º 1
0
        public async Task Can_Get_SystemRelations_Defined_In_Organization()
        {
            //Arrange
            var input1 = await PrepareFullRelationAsync(false, false, false);

            var input2 = await PrepareFullRelationAsync(false, false, false);

            var input3 = await PrepareFullRelationAsync(false, false, false);

            var input4 = await PrepareFullRelationAsync(false, false, false);

            await SystemRelationHelper.PostRelationAsync(input1);

            await SystemRelationHelper.PostRelationAsync(input2);

            await SystemRelationHelper.PostRelationAsync(input3);

            await SystemRelationHelper.PostRelationAsync(input4);

            const int pageSize         = 2;
            const int firstPageNumber  = 0;
            const int secondPageNumber = firstPageNumber + 1;
            var       twoPages         = (await SystemRelationHelper.GetRelationsDefinedInOrganization(TestEnvironment.DefaultOrganizationId, firstPageNumber, pageSize * 2)).ToList();

            Assert.Equal(pageSize * 2, twoPages.Count); //We expect all 4 to be there

            //Act
            var firstPage = await SystemRelationHelper.GetRelationsDefinedInOrganization(TestEnvironment.DefaultOrganizationId, firstPageNumber, pageSize);

            var secondPage = await SystemRelationHelper.GetRelationsDefinedInOrganization(TestEnvironment.DefaultOrganizationId, secondPageNumber, pageSize);

            //Assert - first page with 2 items
            Assert.Equal(twoPages.Take(pageSize).Select(x => x.Id), firstPage.Select(x => x.Id));

            //Assert - second page with 1 item since there are only 3 in total
            Assert.Equal(twoPages.Skip(pageSize).Take(pageSize).Select(x => x.Id).ToList(), secondPage.Select(x => x.Id).ToList());
        }