public async Task <CryptoCurrencyQuotesData> GetCryptoCurrencyQuotesAsync(GetCryptoCurrencyQuotes request)
        {
            try
            {
                _logger.LogDebug($"Getting Crypto Currency Quotes. Request: {request}");

                var response = await _httpClient.GetAsync($"cryptocurrency/quotes/latest?id={string.Join(',', request.CryptoCurrencies)}&convert={string.Join(',', request.ConvertCurrencies)}");

                if (!response.IsSuccessStatusCode)
                {
                    _logger.LogError($"Getting Crypto Currency Quotes Failed. Request: {request}");
                    return(null);
                }

                var result = JsonConvert.DeserializeObject <CryptoCurrencyQuotesData>(await response.Content.ReadAsStringAsync());

                _logger.LogDebug($"Getting Crypto Currency Quotes Finished. Request: {request} Response: {result}");

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An Error Has Occureated In Getting Crypto Currencies");

                return(null);
            }
        }
        public async Task GetCryptoCurrencyQuoteAsync_CryptoCurrencyQuoteWithExchangeApproach_VerifyCoinMarketCapProxyMethodsVerifyExchangeRatesProxyOnce()
        {
            // Arrange
            Initialize();
            _appSettings.CalculateQuoteApproach = "CryptoCurrencyQuoteWithExchangeApproach";
            _appSettings.Currencies             = new List <string> {
                "USD", "EUR"
            };
            _appSettings.BaseCurrency = "USD";
            _appSettings.MaximumFloatingPointDigit = 3;

            string cryptoCurrencySymbol = "BTN";
            int    cryptoCurrencyId     = 1;

            var request = new GetCryptoCurrencyQuoteRequest
            {
                CryptoCurrencySymbol = cryptoCurrencySymbol
            };

            GetCryptoCurrencies getCryptoCurrenciesResponse = new GetCryptoCurrencies
            {
                CryptoCurrencies = new List <CryptoCurrencyData>
                {
                    new CryptoCurrencyData
                    {
                        Id       = cryptoCurrencyId,
                        Name     = "Bitcoin",
                        Symbol   = cryptoCurrencySymbol,
                        IsActive = true
                    }
                },
                Status = new StatusData
                {
                    ErrorCode = 0
                }
            };

            _coinMarketCapProxy.Setup(x => x.GetCryptoCurrenciesAsync()).ReturnsAsync(getCryptoCurrenciesResponse);

            GetCryptoCurrencyQuotes getCryptoCurrencyQuotesRequestForUSD = null;
            decimal usdPrice = 100000;
            CryptoCurrencyQuotesData getCryptoCurrencyQuotesResponseForUSD = new CryptoCurrencyQuotesData
            {
                Data = new Dictionary <string, CryptoCurrencyQuoteData> {
                    { cryptoCurrencyId.ToString(), new CryptoCurrencyQuoteData {
                          Id = cryptoCurrencyId, Quotes = new Dictionary <string, QuoteData> {
                              { "USD", new QuoteData {
                                                                                                         Price = usdPrice
                                                                                                     } }
                          }
                      } }
                }
            };

            _coinMarketCapProxy.Setup(x => x.GetCryptoCurrencyQuotesAsync(It.IsAny <GetCryptoCurrencyQuotes>()))
            .Callback <GetCryptoCurrencyQuotes>(x => getCryptoCurrencyQuotesRequestForUSD = x)
            .ReturnsAsync(getCryptoCurrencyQuotesResponseForUSD);


            decimal         eurRateToUsd     = 0.1m;
            GetExchangeData exchangeRequest  = null;
            ExchangeData    exchangeResponse = new ExchangeData
            {
                Base  = _appSettings.BaseCurrency,
                Rates = new Dictionary <string, decimal> {
                    { "EUR", eurRateToUsd }
                }
            };

            _exchangeRatesProxy.Setup(x => x.GetExchangeRateAsync(It.IsAny <GetExchangeData>())).Callback <GetExchangeData>(x => exchangeRequest = x).ReturnsAsync(exchangeResponse);


            // Act
            var result = await _cryptoCurrencyService.GetCryptoCurrencyQuoteAsync(request).ConfigureAwait(false);

            // Assert
            Assert.NotNull(result);
            Assert.True(result.Success);
            Assert.Equal("Success", result.Message);
            Assert.NotNull(result.Quotes);
            Assert.Equal(cryptoCurrencySymbol, result.CryptoCurrencySymbol);

            Assert.True(result.Quotes.Count() == 2);
            var usdQuote = result.Quotes.FirstOrDefault(x => x.Key == "USD");

            Assert.NotNull(usdQuote);
            Assert.Equal(usdPrice, usdQuote.Value);
            var eurQuote = result.Quotes.FirstOrDefault(x => x.Key == "EUR");

            Assert.NotNull(eurQuote);
            Assert.Equal(decimal.Round(eurRateToUsd * usdPrice, _appSettings.MaximumFloatingPointDigit), eurQuote.Value);


            _coinMarketCapProxy.Verify(x => x.GetCryptoCurrenciesAsync(), Times.Once);
            _exchangeRatesProxy.Verify(x => x.GetExchangeRateAsync(It.IsAny <GetExchangeData>()), Times.Once);
            Assert.NotNull(exchangeRequest);
            Assert.Equal(_appSettings.BaseCurrency, exchangeRequest.BaseCurrency);
            Assert.NotNull(exchangeRequest.TargetCurrencies);
            Assert.True(_appSettings.Currencies.Count() == exchangeRequest.TargetCurrencies.Count());

            foreach (var currency in _appSettings.Currencies)
            {
                Assert.Contains(currency, exchangeRequest.TargetCurrencies);
            }

            _coinMarketCapProxy.Verify(x => x.GetCryptoCurrencyQuotesAsync(It.IsAny <GetCryptoCurrencyQuotes>()), Times.Once);

            Assert.NotNull(getCryptoCurrencyQuotesRequestForUSD);
            Assert.NotNull(getCryptoCurrencyQuotesRequestForUSD.CryptoCurrencies);
            Assert.True(getCryptoCurrencyQuotesRequestForUSD.CryptoCurrencies.Count() == 1);
            Assert.Contains(cryptoCurrencyId, getCryptoCurrencyQuotesRequestForUSD.CryptoCurrencies);

            Assert.NotNull(getCryptoCurrencyQuotesRequestForUSD.ConvertCurrencies);
            Assert.True(getCryptoCurrencyQuotesRequestForUSD.ConvertCurrencies.Count() == 1);
            Assert.Contains("USD", getCryptoCurrencyQuotesRequestForUSD.ConvertCurrencies);
        }