internal Task FinalizeCacheHeadersAsync(ResponseCachingContext context)
 {
     if (OnFinalizeCacheHeaders(context))
     {
         return(_cache.SetAsync(context.BaseKey, context.CachedVaryByRules, context.CachedResponseValidFor));
     }
     return(Task.CompletedTask);
 }
Example #2
0
        public void SetAsyncCallsSerializerAndCache()
        {
            _distributedResponseCache.SetAsync(Key, _deserializedValue, default(TimeSpan));

            A.CallTo(() => _fakeCacheSerializer.Serialize(_deserializedValue))
            .MustHaveHappenedOnceExactly();

            A.CallTo(() => _fakeDistributedCache.SetAsync(Key, _serializedValue, A <DistributedCacheEntryOptions> ._, A <CancellationToken> ._))
            .MustHaveHappenedOnceExactly();
        }
 public async void SetASyncInvalidCacheEntryTypeThrowsException()
 {
     var unsupportedCacheEntry = new UnsupportedResponseCacheEntry();
     await Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                          _distributedResponseCache.SetAsync(Key, unsupportedCacheEntry, default(TimeSpan)));
 }