public async Task MapsPagingProperties() { // given var subject = new CustomersClient(_clientConfiguration); var firstPageRequest = new GetCustomersRequest { Limit = 1 }; // when var firstPageResult = await subject.GetPageAsync(firstPageRequest); var secondPageRequest = new GetCustomersRequest { After = firstPageResult.Meta.Cursors.After, Limit = 2 }; 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 async Task ReturnsCustomers() { // given var subject = new CustomersClient(_clientConfiguration); // when var result = (await subject.GetPageAsync()).Items.ToList(); // then Assert.That(result.Any(), Is.True); Assert.That(result[0], Is.Not.Null); Assert.That(result[0].Id, Is.Not.Null); Assert.That(result[0].AddressLine1, Is.Not.Null); Assert.That(result[0].AddressLine2, Is.Not.Null); Assert.That(result[0].AddressLine3, Is.Not.Null); Assert.That(result[0].City, Is.Not.Null); Assert.That(result[0].CountryCode, Is.Not.Null); Assert.That(result[0].CreatedAt, Is.Not.EqualTo(default(DateTimeOffset))); Assert.That(result[0].DanishIdentityNumber, Is.Not.Null); Assert.That(result[0].Email, Is.Not.Null); Assert.That(result[0].FamilyName, Is.Not.Null); Assert.That(result[0].GivenName, Is.Not.Null); Assert.That(result[0].Language, Is.Not.Null); Assert.That(result[0].Metadata, Is.Not.Null); Assert.That(result[0].PhoneNumber, Is.Not.Null); Assert.That(result[0].PostalCode, Is.Not.Null); Assert.That(result[0].Region, Is.Not.Null); Assert.That(result[0].SwedishIdentityNumber, Is.Not.Null); }
public async Task CallsGetCustomersEndpoint() { // given var subject = new CustomersClient(_clientConfiguration); // when await subject.GetPageAsync(); // then _httpTest .ShouldHaveCalled("https://api.gocardless.com/customers") .WithVerb(HttpMethod.Get); }
public void GetCustomersRequestIsNullThrows() { // given var subject = new CustomersClient(_clientConfiguration); GetCustomersRequest 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 CallsGetCustomersEndpointUsingRequest() { // given var subject = new CustomersClient(_clientConfiguration); var request = new GetCustomersRequest { Before = "before test", After = "after test", Limit = 5 }; // when await subject.GetPageAsync(request); // then _httpTest .ShouldHaveCalled("https://api.gocardless.com/customers?before=before%20test&after=after%20test&limit=5") .WithVerb(HttpMethod.Get); }
public async Task PagesThroughCustomers() { // given var subject = new CustomersClient(_clientConfiguration); var firstId = (await subject.GetPageAsync()).Items.First().Id; var initialRequest = new GetCustomersRequest { After = firstId, CreatedGreaterThan = new DateTimeOffset(DateTime.Now.AddDays(-1)), 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)); }