public void TryGetCurrencies_NoDateProvided_ShouldReturnDailyCurrencies() { ILogger <CurrencyFetchingService> loggerMock = Mock.Of <ILogger <CurrencyFetchingService> >(); ICurrencyCachingService currencyCachingService = Mock.Of <ICurrencyCachingService>(); ICurrencyParsingService currencyParsingService = new CurrencyParsingService(); Mock <IOptions <UrlsConfig> > urlsConfigMock = new Mock <IOptions <UrlsConfig> >(); Mock <IOptions <CacheKeyConfig> > cacheConfigMock = new Mock <IOptions <CacheKeyConfig> >(); urlsConfigMock.SetupGet(x => x.Value).Returns(new UrlsConfig { DailyCurrencies = _dailyCurrencies, CurrenciesHistory = null, }); cacheConfigMock.SetupGet(x => x.Value).Returns(new CacheKeyConfig { Format = _cacheKeyDateFormat, }); CurrencyFetchingService currencyFetchingService = new CurrencyFetchingService( currencyCachingService, currencyParsingService, loggerMock, urlsConfigMock.Object, cacheConfigMock.Object ); bool result = currencyFetchingService.TryGetCurrencies(null, out SingleDayCurrencies currencies, out string error); Assert.IsTrue(result); Assert.IsNull(error); Assert.IsTrue(!string.IsNullOrEmpty(currencies.Date)); }
public CurrencyFetchingService( ICurrencyCachingService currencyCachingService, ICurrencyParsingService currencyParsingService, ILogger <CurrencyFetchingService> logger, IOptions <UrlsConfig> urlsConfig, IOptions <CacheKeyConfig> cacheKeyConfig) { _currencyCachingService = currencyCachingService; _currencyParsingService = currencyParsingService; _logger = logger; _urlsConfig = urlsConfig.Value; _cacheKeyConfig = cacheKeyConfig.Value; }