Exemplo n.º 1
0
        public async Task GetWalletsAsync_should_return_results()
        {
            var wallets = (await _walletsClient.GetWalletsAsync()).Result;

            Logger.Information("Found wallets: {wallets}",
                               JsonSerializer.Serialize(wallets, new JsonSerializerOptions {
                WriteIndented = true
            }));

            wallets.Data.Count.Should().BeGreaterOrEqualTo(1);
        }
        public static async IAsyncEnumerable <Wallet> GetWallets(this IWalletsClient walletsClient,
                                                                 string?currency = null, Pagination?pagination = null,
                                                                 [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            pagination ??= Pagination.Default;
            var fetchPage = new Func <Pagination, Task <IPagedResponse <Wallet> > >(async p =>
            {
                var page = await walletsClient.GetWalletsAsync(currency, p?.Limit, p?.Before, p?.After, cancellationToken);
                return(page.Result);
            });

            await foreach (var wallet in pagination.EnumerateAsynchronously(fetchPage)
                           .WithCancellation(cancellationToken))
            {
                yield return(wallet);
            }
        }