コード例 #1
0
        public async Task Previous_FirstPage_ReturnsNull()
        {
            ClientRequestParameters parameters = new ClientRequestParameters()
            {
                Pagination = new ClientRequestPagination()
                {
                    Page = 1
                }
            };

            ClientResponse <IList <ModelBase> > response = UKFastClientTests.GetListResponse(new List <ModelBase>(), 3);

            Paginated <ModelBase> paginated = new Paginated <ModelBase>(null, null, parameters, response);

            Paginated <ModelBase> previous = await paginated.Previous();

            Assert.IsNull(previous);
        }
コード例 #2
0
        public async Task Previous_NotFirstPage_ReturnsPreviousPage()
        {
            ClientResponse <IList <ModelBase> > paginatedResponse = UKFastClientTests.GetListResponse(new List <ModelBase>(), 3);
            ClientResponse <IList <ModelBase> > mockResponse      = UKFastClientTests.GetListResponse(new List <ModelBase>(), 3);

            IUKFastClient client = Substitute.For <IUKFastClient>();

            client.GetPaginatedAsync <ModelBase>("testresource", Arg.Any <ClientRequestParameters>()).Returns(x =>
            {
                return(Task.Run(() => new Paginated <ModelBase>(client, "testresource", x.ArgAt <ClientRequestParameters>(1), mockResponse)));
            });

            Paginated <ModelBase> paginated = new Paginated <ModelBase>(client, "testresource", new ClientRequestParameters()
            {
                Pagination = new ClientRequestPagination()
                {
                    Page = 3
                }
            }, paginatedResponse);

            Paginated <ModelBase> previous = await paginated.Previous();

            Assert.AreEqual(2, previous.CurrentPage);
        }