Пример #1
0
    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));
    }
Пример #2
0
    public async Task EmptyContent()
    {
        var content = await httpCache.DownloadAsync("https://httpbin.org/status/200");

        await Verifier.Verify(content);
    }