public async Task ServerErrorDontUseStale() { using HttpResponseMessage response = new(HttpStatusCode.OK) { Content = new StringContent("foo") }; var uri = "https://httpbin.org/status/500"; await httpCache.AddItemAsync(uri, response); await Verifier.ThrowsTask(() => httpCache.StringAsync(uri)); }
public async Task TimeoutUseStale() { HttpClient httpClient = new() { Timeout = TimeSpan.FromMilliseconds(1) }; httpCache = new(CachePath, httpClient); httpCache.Purge(); var uri = "https://httpbin.org/delay/1"; #region AddItem using HttpResponseMessage response = new(HttpStatusCode.OK) { Content = new StringContent("the content") }; await httpCache.AddItemAsync(uri, response); #endregion await Verifier.Verify(httpCache.DownloadAsync(uri, true)); }