public async Task CacheIsUtilized() { ICurrencyRateProvider wrappedProvider = _fixture.BasicProvider; CachingCurrencyRateProvider provider = new CachingCurrencyRateProvider(wrappedProvider, TimeSpan.FromDays(1)); // Act: var result0 = await provider.GetCurrentRatesAsync(); var result1 = await provider.GetCurrentRatesAsync(); // Assert: Assert.Same(result0, result1); }
public async Task CacheIsRefreshedAfterTimeout() { ICurrencyRateProvider wrappedProvider = _fixture.BasicProvider; CachingCurrencyRateProvider provider = new CachingCurrencyRateProvider(wrappedProvider, TimeSpan.FromMilliseconds(1)); // Act: var result0 = await provider.GetCurrentRatesAsync(); await Task.Delay(5); var result1 = await provider.GetCurrentRatesAsync(); // Assert: Assert.NotSame(result0, result1); }
public async Task AutoAddEur() { ICurrencyRateProvider wrappedProvider = _fixture.BasicProvider; CachingCurrencyRateProvider provider = new CachingCurrencyRateProvider(wrappedProvider, TimeSpan.FromDays(1), true); var snapshot = await provider.GetCurrentRatesAsync(); Assert.Equal(CurrencyRate.Eur, snapshot[CurrencyCode.Eur]); }
public async Task ReturnsCorrectResult() { ICurrencyRateProvider wrappedProvider = _fixture.BasicProvider; CachingCurrencyRateProvider provider = new CachingCurrencyRateProvider(wrappedProvider, TimeSpan.FromHours(1)); // Act: var result = await provider.GetCurrentRatesAsync(); // Assert: Assert.Equal(_fixture.ExpectedRates1.Count, result.Count); }