public async void GetCoinDetail_returns_coin_details() { var client = new CoinGeckoClient(); var coin = await client.GetCoinDetail("bitcoin"); Assert.NotNull(coin); Assert.Equal("Bitcoin", coin.Name); Assert.Equal("btc", coin.Symbol); }
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}'."); }