public async Task HasPrevious_True()
        {
            // arrange
            var list = new List <string> {
                "a", "b", "c", "d", "e", "f", "g",
            };

            var connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), new PagingDetails {
                First = 1
            });

            Connection <string> connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            var pagingDetails = new PagingDetails
            {
                After = connection.PageInfo.StartCursor,
                First = 2
            };

            connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), pagingDetails);

            // act
            connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            // assert
            Assert.True(connection.PageInfo.HasPreviousPage);
        }
        public async Task TakeFirstAfter()
        {
            // arrange
            var list = new List <string> {
                "a", "b", "c", "d", "e", "f", "g",
            };

            var connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), new PagingDetails {
                First = 1
            });

            Connection <string> connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            var pagingDetails = new PagingDetails
            {
                After = connection.PageInfo.StartCursor,
                First = 2
            };

            connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), pagingDetails);

            // act
            connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            // assert
            Assert.Collection(connection.Edges,
                              t =>
            {
                Assert.Equal("b", t.Node);
                Assert.Equal(1, GetPositionFromCursor(t.Cursor));
            },
                              t =>
            {
                Assert.Equal("c", t.Node);
                Assert.Equal(2, GetPositionFromCursor(t.Cursor));
            });

            Assert.True(
                connection.PageInfo.HasPreviousPage,
                "HasPreviousPage");

            Assert.True(
                connection.PageInfo.HasNextPage,
                "HasNextPage");
        }
        public async Task HasPrevious_False()
        {
            // arrange
            var list = new List <string> {
                "a", "b", "c", "d", "e", "f", "g",
            };

            var pagingDetails = new PagingDetails();

            var connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), pagingDetails);

            // act
            Connection <string> connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            // assert
            Assert.False(connection.PageInfo.HasPreviousPage);
        }
Пример #4
0
        public async Task HasNextPage_True()
        {
            // arrange
            var list = new List <string> {
                "a", "b", "c", "d", "e", "f", "g",
            };

            var pagingDetails = new PagingDetails
            {
                First = 5
            };

            var connectionFactory = new QueryableConnectionResolver <string>(
                list.AsQueryable(), pagingDetails);

            // act
            var connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            // assert
            Assert.True(connection.PageInfo.HasNextPage);
        }