public async Task MapsPagingProperties() { // given var subject = new RefundsClient(_clientConfiguration); var firstPageRequest = new GetRefundsRequest { Limit = 1 }; // when var firstPageResult = await subject.GetPageAsync(firstPageRequest); var secondPageRequest = new GetRefundsRequest { After = firstPageResult.Meta.Cursors.After, Limit = 1 }; 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.Not.Null); }
public void GetRefundsRequestIsNullThrows() { // given var subject = new RefundsClient(_clientConfiguration); GetRefundsRequest request = null; // when AsyncTestDelegate test = () => subject.GetPageAsync(request); // then var ex = Assert.ThrowsAsync <ArgumentNullException>(test); Assert.That(ex.ParamName, Is.EqualTo(nameof(request))); }
public async Task CallsGetRefundsEndpointUsingRequest() { // given var subject = new RefundsClient(_clientConfiguration); var request = new GetRefundsRequest { Before = "before test", After = "after test", Limit = 5 }; // when await subject.GetPageAsync(request); // then _httpTest .ShouldHaveCalled("https://api.gocardless.com/refunds?before=before%20test&after=after%20test&limit=5") .WithVerb(HttpMethod.Get); }
public async Task PagesThroughRefunds() { // given var subject = new RefundsClient(_clientConfiguration); var firstId = (await subject.GetPageAsync()).Items.First().Id; var initialRequest = new GetRefundsRequest { Limit = 1 }; // when var result = await subject .BuildPager() .StartFrom(initialRequest) .AndGetAllAfterAsync(); // then Assert.That(result.Count, Is.GreaterThan(1)); Assert.That(result[0].Id, Is.Not.Null.And.Not.EqualTo(result[1].Id)); Assert.That(result[1].Id, Is.Not.Null.And.Not.EqualTo(result[0].Id)); }