示例#1
0
        public async Task First_ReturnsFirstPage()
        {
            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.Is <ClientRequestParameters>(x => x.Pagination.Page == 1)).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(), paginatedResponse);
            Paginated <ModelBase> first     = await paginated.First();

            Assert.AreEqual(1, first.CurrentPage);
        }