public async void WithCacheKeyAndType_ShouldCacheObj() { var cache = ServicesCreateMethods.CreateCache(); var service = this.GetService(cache); var cacheKey = Guid.NewGuid().ToString(); var cacheType = Guid.NewGuid().ToString(); await service.AddInfinityCacheAsync(new object(), cacheKey, cacheType); Assert.True(cache.Get(cacheKey).Length > 0); }
public async void WithCache_ShouldReturnCache() { var cache = ServicesCreateMethods.CreateCache(); var service = this.GetService(cache); var cacheKey = Guid.NewGuid().ToString(); var str = Guid.NewGuid().ToString(); var seriazedStr = this.GetSerializedTring(str); cache.SetString(cacheKey, seriazedStr); var result = await service.GetOrDefaultAsync <string>(cacheKey); Assert.Equal(str, result); }
public async void WithCorrectParameters_ShouldCacheObj() { var cache = ServicesCreateMethods.CreateCache(); var service = this.GetService(cache); var obj = Guid.NewGuid().ToString(); var cacheKey = Guid.NewGuid().ToString(); var cacheType = Guid.NewGuid().ToString(); var expirationDate = DateTime.UtcNow.AddDays(1); await service.AddTimedCacheAsync(obj, cacheKey, cacheType, expirationDate); Assert.True(cache.Get(cacheKey).Length > 0); }