public async Task SetAndGetExisting() { var store = new ImmutableInMemoryCacheStore(); var resp = new HttpResponseMessage(); var cacheKey = new CacheKey("key", null); await store.SetAsync(cacheKey, new CacheEntry(resp)); var respNew = new HttpResponseMessage(); // overwrite await store.SetAsync(cacheKey, new CacheEntry(respNew)); var fromCache = await store.GetAsync(cacheKey); // check Assert.AreEqual(respNew, fromCache.HttpResponse); }
public async Task GetNonExisting() { var store = new ImmutableInMemoryCacheStore(); var resp = new HttpResponseMessage(); var cacheKey = new CacheKey("key", null); await store.SetAsync(cacheKey, new CacheEntry(resp)); var fromCache = await store.GetAsync("key2"); // check Assert.AreEqual(default(CacheEntry), fromCache); }
public async Task SetAndGetMultiple() { var store = new ImmutableInMemoryCacheStore(); var resp = new HttpResponseMessage(); var resp2 = new HttpResponseMessage(); var cacheKey = new CacheKey("key", null); var cacheKey2 = new CacheKey("key2", null); await store.SetAsync(cacheKey, new CacheEntry(resp)); await store.SetAsync(cacheKey2, new CacheEntry(resp2)); var fromCache = await store.GetAsync(cacheKey); var fromCache2 = await store.GetAsync(cacheKey2); // check Assert.AreEqual(resp, fromCache.HttpResponse); // check Assert.AreEqual(resp2, fromCache2.HttpResponse); }
public async Task SetAndGetTestCacheKeyEquality() { var store = new ImmutableInMemoryCacheStore(); var resp = new HttpResponseMessage(); var cacheKey = new CacheKey("key", null); await store.SetAsync(cacheKey, new CacheEntry(resp)); var fromCache = await store.GetAsync(new CacheKey("key", null)); // check Assert.AreEqual(resp, fromCache.HttpResponse); }