public void ZeroTimeoutDoesNotStartAsyncAction() { bool _hasRun = false; Assert.Throws <SyntheticTimeoutException>(() => { FusionCacheExecutionUtils.RunAsyncActionWithTimeout(async ct => { _hasRun = true; }, TimeSpan.Zero, false, t => { }); }); Assert.False(_hasRun); }
public void DoNotCancelWhenTimeoutActuallyWorks() { var factoryCompleted = false; var timeoutMs = 500; var innerDelayMs = 2_000; Assert.ThrowsAny <TimeoutException>(() => { FusionCacheExecutionUtils.RunAsyncActionWithTimeout(async ct => { await Task.Delay(innerDelayMs); ct.ThrowIfCancellationRequested(); factoryCompleted = true; }, TimeSpan.FromMilliseconds(timeoutMs), false); }); Thread.Sleep(innerDelayMs); Assert.True(factoryCompleted); }