public ConversionRateHistoryDto GetConversionRateHistoricDataAsync(string fromCurrency, string toCurrency)
        {
            if (string.IsNullOrEmpty(fromCurrency) || string.IsNullOrEmpty(toCurrency))
            {
                return(new ConversionRateHistoryDto()
                {
                    ErrorCode = ErrorCode.CurrencyNotProvided
                });
            }

            var dbContext = BuildDbContext();

            var rates = dbContext.ExchangeRates
                        .Where(rate => rate.Currency == fromCurrency || rate.Currency == toCurrency);

            var distinctDates = rates.Select(rate => rate.Date).Distinct();

            var dto = new ConversionRateHistoryDto()
            {
                FromCurrency         = fromCurrency,
                ToCurrency           = toCurrency,
                DailyConversionRates = CalculateDailyConversionRates(distinctDates, rates, fromCurrency, toCurrency).OrderByDescending(rate => rate.Date)
            };

            return(dto);
        }
        public async void GetExchangeRateHistoricDataAsync_ReturnsCorrectResult()
        {
            var responseDto = new ConversionRateHistoryDto()
            {
                FromCurrency         = "EUR",
                ToCurrency           = "EUR",
                DailyConversionRates = new List <DailyConversionRate>()
            };

            _mockExchangeRatesService.Setup(x =>
                                            x.GetConversionRateHistoricDataAsync(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(responseDto);

            var result = _mockExchangeRatesService.Object.GetConversionRateHistoricDataAsync("EUR", "EUR");

            Assert.IsType <ConversionRateHistoryDto>(result);
            Assert.Equal(responseDto.FromCurrency, result.FromCurrency);
            Assert.Equal(responseDto.ToCurrency, result.ToCurrency);
            Assert.Empty(result.DailyConversionRates);
        }