public void SetCacheExpiryTimeShouldThrowIfExpiryTimeTooLong() { var cache = new NoExpiryLimitCache(); cache.SetCacheExpiryLimit <ProviderMetadata>(TimeSpan.FromSeconds(200), TimeSpan.FromSeconds(400)); Assert.Throws <MobileConnectCacheExpiryLimitException>(() => cache.SetCacheExpiryTime <ProviderMetadata>(TimeSpan.FromSeconds(600))); }
public async Task CacheShouldNotReturnValueIfExpiredAndRemoveIfExpiredIsTrue() { var cache = new NoExpiryLimitCache(); cache.SetCacheExpiryTime <ProviderMetadata>(TimeSpan.Zero); var value = new ProviderMetadata(); var key = "test"; await cache.Add(key, value); await Task.Delay(50); var cached = await cache.Get <ProviderMetadata>(key, true); Assert.IsNull(cached); }