Пример #1
0
        public async Task GetPaginatedResponseAsync_NullParameters_ExpectedConfiguredParameters()
        {
            var mockResponse = GetListResponse(new List <ModelBase>(), 3);

            mockResponse.StatusCode = 200;

            IConnection connection = NSubstitute.Substitute.For <IConnection>();

            connection.GetAsync <IList <ModelBase> >("testresource", Arg.Any <ClientRequestParameters>()).Returns(Task.Run(() => mockResponse));

            TestUKFastClient client = new TestUKFastClient(connection, new ClientConfig()
            {
                PaginationDefaultPerPage = 99
            });

            await client.GetPaginatedAsync <ModelBase>("testresource");

            await connection.Received().GetAsync <IList <ModelBase> >("testresource", Arg.Is <ClientRequestParameters>(x => x.Pagination.PerPage == 99));
        }
Пример #2
0
        public async Task GetPaginatedResponseAsync_ExpectedResult()
        {
            var mockResponse = GetListResponse(new List <ModelBase>()
            {
                new ModelBase(),
                new ModelBase()
            }, 3);

            mockResponse.StatusCode = 200;

            IConnection connection = NSubstitute.Substitute.For <IConnection>();

            connection.GetAsync <IList <ModelBase> >("testresource", Arg.Any <ClientRequestParameters>()).Returns(Task.Run(() => mockResponse));

            TestUKFastClient client = new TestUKFastClient(connection);

            var result = await client.GetPaginatedAsync <ModelBase>("testresource");

            Assert.AreEqual(2, result.Items.Count);
            Assert.AreEqual(3, result.TotalPages);
        }