Пример #1
0
        public async Task GetResponseAsync_ReturnsCachedResponse(ErgastResponse expectedResponse)
        {
            Cache.Get <ErgastResponse>(null).ReturnsForAnyArgs(expectedResponse);

            var response = await Client.GetResponseAsync(NullRequest);

            response.Should().Be(expectedResponse);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public void AddOrReplace(string url, ErgastResponse response)
        {
            var expiration = DateTimeOffset.UtcNow + CacheEntryLifetime;

            var entry = new CacheEntry <ErgastResponse>
            {
                Item       = response,
                Expiration = expiration
            };

            Cache[url] = entry;
        }
Пример #4
0
 public void AddOrReplace(string url, ErgastResponse response)
 {
     Cache.Set(url, response, DateTimeOffset.UtcNow + CacheEntryLifetime);
 }