public async Task GetResponseAsync_ReturnsCachedResponse(ErgastResponse expectedResponse) { Cache.Get <ErgastResponse>(null).ReturnsForAnyArgs(expectedResponse); var response = await Client.GetResponseAsync(NullRequest); response.Should().Be(expectedResponse); }
public void CachedResponseIsReturned(string url, ErgastResponse response) { // Arrange Cache.CacheEntryLifetime = TimeSpan.FromMinutes(1); Cache.AddOrReplace(url, response); // Act var cachedResponse = Cache.Get <ErgastResponse>(url); // Assert cachedResponse.Should().Be(response); }
public void AddOrReplace(string url, ErgastResponse response) { var expiration = DateTimeOffset.UtcNow + CacheEntryLifetime; var entry = new CacheEntry <ErgastResponse> { Item = response, Expiration = expiration }; Cache[url] = entry; }
public void AddOrReplace(string url, ErgastResponse response) { Cache.Set(url, response, DateTimeOffset.UtcNow + CacheEntryLifetime); }