private async Task SynchronizeCheckIntervalAsync()
 {
     try
     {
         await _timeCoordinator.Delay(await _healthCheckInterval.GetValueAsync(), _cancelationTokenSource.Token);
     }
     catch (OperationCanceledException) when(_cancelationTokenSource.IsCancellationRequested)
     {
     }
     catch (Exception e)
     {
         _logger.Error("Health check loop synchrnonisation failed.", e);
     }
 }
Exemplo n.º 2
0
        public async Task GetValueAsync_GetOrAddModeWithRegions_ReturnsValueFromCache()
        {
            Func <string> getValue = () => "Test1234";

            var cache = A.Fake <ICache <int, string> >(x => x.Strict());

            A.CallTo(() => cache.GetOrAddAsync(1, getValue, CacheExpirationPolicy.NeverExpire, "Region1"))
            .Returns(Task.FromResult(getValue()));

            var cachedValue = new CachedValue <int, string>(cache, 1, getValue, CacheExpirationPolicy.NeverExpire, "Region1");

            var value = await cachedValue.GetValueAsync();

            Assert.Equal("Test1234", value);
            A.CallTo(() => cache.GetOrAddAsync(1, getValue, CacheExpirationPolicy.NeverExpire, "Region1"))
            .MustHaveHappenedOnceExactly();
        }
Exemplo n.º 3
0
        public async Task GetValueAsync_GetValueOrDefaultModeWithRegions_ReturnsValueFromCache()
        {
            const string expectedValue = "Test1234";

            var cache = A.Fake <ICache <int, string> >(x => x.Strict());

            A.CallTo(() => cache.TryGetAsync(1, "region1"))
            .Returns(Task.FromResult(new CacheRequestResult <string>(true, expectedValue)));

            var cachedValue = new CachedValue <int, string>(cache, 1, "Text", "region1");

            var value = await cachedValue.GetValueAsync();

            Assert.Equal(expectedValue, value);
            A.CallTo(() => cache.TryGetAsync(1, "region1"))
            .MustHaveHappenedOnceExactly();
        }