Beispiel #1
0
        public async Task MapsPagingProperties()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var firstPageRequest = new GetPayoutItemsRequest
            {
                Limit  = 1,
                Payout = _payout.Id
            };

            // when
            var firstPageResult = await subject.GetPageAsync(firstPageRequest);

            var secondPageRequest = new GetPayoutItemsRequest
            {
                After  = firstPageResult.Meta.Cursors.After,
                Limit  = 1,
                Payout = _payout.Id
            };

            var secondPageResult = await subject.GetPageAsync(secondPageRequest);

            // then
            Assert.That(firstPageResult.Items.Count(), Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Limit, Is.EqualTo(firstPageRequest.Limit));
            Assert.That(firstPageResult.Meta.Cursors.Before, Is.Null);
            Assert.That(firstPageResult.Meta.Cursors.After, Is.Not.Null);

            Assert.That(secondPageResult.Items.Count(), Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Limit, Is.EqualTo(secondPageRequest.Limit));
            Assert.That(secondPageResult.Meta.Cursors.Before, Is.Not.Null);
            Assert.That(secondPageResult.Meta.Cursors.After, Is.Null);
        }
        public void GetPayoutItemRequestIsNullThrows()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            GetPayoutItemsRequest request = null;

            // when
            AsyncTestDelegate test = () => subject.GetPageAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentNullException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
        public void PayoutIdIsNullOrWhiteSpaceThrows(string payoutId)
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Payout = payoutId
            };

            // when
            AsyncTestDelegate test = () => subject.GetPageAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentException>(test);

            Assert.That(ex.Message, Is.Not.Null);
            Assert.That(ex.ParamName, Is.EqualTo(nameof(request.Payout)));
        }
        public async Task CallsGetPayoutItemsEndpointUsingRequest()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Before = "before test",
                After  = "after test",
                Limit  = 5,
                Payout = "PO12345678"
            };

            // when
            await subject.GetPageAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/payout_items?before=before%20test&after=after%20test&limit=5&payout=PO12345678")
            .WithVerb(HttpMethod.Get);
        }
Beispiel #5
0
        public async Task ReturnsPayoutItems()
        {
            // given
            var subject = new PayoutItemsClient(_clientConfiguration);

            var request = new GetPayoutItemsRequest
            {
                Payout = _payout.Id
            };

            // when
            var result = await subject.GetPageAsync(request);

            var actual = result.Items.ToList();

            // then
            Assert.That(actual[0].Amount, Is.Not.Null);
            Assert.That(actual[0].Links, Is.Not.Null);
            Assert.That(actual[0].Links.Payment, Is.Not.Null);
            Assert.That(actual[0].Type, Is.Not.Null);
        }