From 827b6085af68269f4c941aa7f7e67ac34779b661 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Fri, 17 Jan 2020 14:56:05 +0900 Subject: [PATCH] Do not hammer CoinGecko with tests --- BTCPayServer.Rating/Providers/CoinGeckoRateProvider.cs | 10 +++++++++- BTCPayServer.Tests/UnitTest1.cs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BTCPayServer.Rating/Providers/CoinGeckoRateProvider.cs b/BTCPayServer.Rating/Providers/CoinGeckoRateProvider.cs index 24d4f4b1e..f1856e2a5 100644 --- a/BTCPayServer.Rating/Providers/CoinGeckoRateProvider.cs +++ b/BTCPayServer.Rating/Providers/CoinGeckoRateProvider.cs @@ -18,6 +18,14 @@ namespace BTCPayServer.Services.Rates public string Exchange { get; set; } public string ExchangeName => Exchange ?? CoinGeckoName; + public bool CoinGeckoRate + { + get + { + return ExchangeName == CoinGeckoName; + } + } + public CoinGeckoRateProvider(IHttpClientFactory httpClientFactory) { if (httpClientFactory == null) @@ -31,7 +39,7 @@ namespace BTCPayServer.Services.Rates public virtual Task GetRatesAsync(CancellationToken cancellationToken) { - return ExchangeName == CoinGeckoName ? GetCoinGeckoRates() : GetCoinGeckoExchangeSpecificRates(); + return CoinGeckoRate ? GetCoinGeckoRates() : GetCoinGeckoExchangeSpecificRates(); } private async Task GetCoinGeckoRates() diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index d813fc10c..74cc6256c 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -2684,7 +2684,7 @@ noninventoryitem: var all = string.Join("\r\n", factory.GetSupportedExchanges().Select(e => e.Id).ToArray()); foreach (var result in factory .Providers - .Where(p => p.Value is BackgroundFetcherRateProvider) + .Where(p => p.Value is BackgroundFetcherRateProvider bf && !(bf.Inner is CoinGeckoRateProvider cg && !cg.CoinGeckoRate)) .Select(p => (ExpectedName: p.Key, ResultAsync: p.Value.GetRatesAsync(default), Fetcher: (BackgroundFetcherRateProvider)p.Value)) .ToList()) {