public async Task TestMemoryCache() { var cache = new AsyncBitmapCache(); const string bitmapFile = "dapplo.png"; var tasks = new List <Task <BitmapSource> >(); for (var i = 0; i < 10; i++) { tasks.Add(cache.GetOrCreateAsync(bitmapFile)); } await Task.WhenAll(tasks); for (var i = 0; i < 10; i++) { var bitmapSource = await tasks[i]; Assert.NotNull(bitmapSource); Assert.True(bitmapSource.Width > 0); Assert.True(bitmapSource.Height > 0); } }
public async Task TestMemoryCacheDelete() { var cache = new AsyncBitmapCache(); const string bitmapFile = "dapplo.png"; var bitmapSource = await cache.GetOrCreateAsync(bitmapFile); Assert.NotNull(bitmapSource); Assert.NotNull(await cache.GetAsync(bitmapFile)); Assert.True(bitmapSource.Width > 0); Assert.True(bitmapSource.Height > 0); await cache.DeleteAsync(bitmapFile); Assert.Null(await cache.GetAsync(bitmapFile)); bitmapSource = await cache.GetOrCreateAsync(bitmapFile); Assert.NotNull(bitmapSource); Assert.True(bitmapSource.Width > 0); Assert.True(bitmapSource.Height > 0); }