public async void GetCoinList_returns_all_coins() { var client = new CoinGeckoClient(); var coins = await client.GetCoinList(); Assert.NotNull(coins); Assert.True(coins.Count > 1000); }
public async Task GenerateCoinDataFile(string fileLocation) { Console.WriteLine($"Generating new CoinData file at '{fileLocation}'."); var coins = await _coinGeckoClient.GetCoinList(); Console.WriteLine($"Coin list downloaded from CoinGecko. {coins.Count} coins found."); var coinDetails = new List <CoinGeckoCoinDetail>(); var counter = 0; var maxApiTimeConstraint = TimeLimiter.GetFromMaxCountByInterval(80, TimeSpan.FromMinutes(1)); foreach (var coin in coins) { await maxApiTimeConstraint; Interlocked.Increment(ref counter); Console.WriteLine($"{counter}/{coins.Count} - Retrieving coin details for {coin.Id} ({coin.Name})."); coinDetails.Add(await _coinGeckoClient.GetCoinDetail(coin.Id)); } Console.WriteLine("Completed downloading all coin details."); Console.WriteLine($"Saving filedata to '{fileLocation}'."); var coinFileData = GetCoinDataFile(coinDetails); File.WriteAllText(fileLocation, coinFileData); Console.WriteLine($"Completed generating new CoinData file at '{fileLocation}'."); }