Beispiel #1
0
        public void Given_CurrencyAndDateRange_When_GetHistoricalInvoked_Then_resultWithHistoricalExchangeRatesRetrived()
        {
            var      currency = "EUR";
            DateTime beginDate = new DateTime(2017, 1, 1), endDate = new DateTime(2017, 12, 31);

            var actionResult = _serviceUnderTest.GetHistorical(currency, beginDate, endDate);

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.All(x => x.To == currency));
            Assert.IsTrue(actionResult.All(x => x.Date >= beginDate && x.Date <= endDate));
        }
        public IActionResult GetHistorical(string currency, string beginDate, string endDate)
        {
            var actionResponse = GetEmptyResponseBuilder <IEnumerable <ExchangeRate> >();

            try
            {
                var parsedBeginDate = ParseDate(beginDate);
                var parsedEndDate   = ParseDate(endDate);

                actionResponse.SetData(_exchangeRateService.GetHistorical(currency, parsedBeginDate.Value, parsedEndDate.Value));

                return(Ok(actionResponse));
            }
            catch (Exception ex)
            {
                return(Ko(actionResponse, ex));
            }
        }