Пример #1
0
        public async Task TakeLast()
        {
            // arrange
            var list = new List <string> {
                "a", "b", "c", "d", "e", "f", "g",
            };

            var pagingDetails = new PagingDetails
            {
                Last = 2
            };

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

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

            // assert
            Assert.Collection(connection.Edges,
                              t =>
            {
                Assert.Equal("f", t.Node);
                Assert.Equal(5, GetPositionFromCursor(t.Cursor));
            },
                              t =>
            {
                Assert.Equal("g", t.Node);
                Assert.Equal(6, GetPositionFromCursor(t.Cursor));
            });
        }
Пример #2
0
        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
            });

            var 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);
        }
Пример #3
0
        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
            var connection = await connectionFactory.ResolveAsync(
                CancellationToken.None);

            // assert
            Assert.False(connection.PageInfo.HasPreviousPage);
        }
Пример #4
0
        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
            });

            var 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));
            });
        }