public async Task Should_WaitForValueAsync() { var lazy = new UpdatableLazy <string>(() => { Task.Delay(ShortDelay).Wait(); return(TestValue); }); Assert.AreEqual(TestValue, await lazy.GetValueAsync()); }
public async Task Should_RetryAsync() { var counter = 0; var lazy = new UpdatableLazy <string>(() => { if (counter++ < DefaultMaxRetries - 1) { throw new Exception(); } return(TestValue); }, DefaultMaxRetries); Assert.AreEqual(TestValue, await lazy.GetValueAsync()); Assert.AreEqual(DefaultMaxRetries, counter); }