public void TryGetCurrencies_WithNoUrlsProvided_ShouldReturnError() { ILogger <CurrencyFetchingService> loggerMock = Mock.Of <ILogger <CurrencyFetchingService> >(); ICurrencyCachingService currencyCachingService = Mock.Of <ICurrencyCachingService>(); ICurrencyParsingService currencyParsingService = Mock.Of <ICurrencyParsingService>(); 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 = null, 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.IsNotNull(error); }
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; }