public void TestInitialize()
        {
            var eventPublisher = new Mock <IMediator>();
            var cacheManager   = new MemoryCacheBase(new Mock <IMemoryCache>().Object, eventPublisher.Object);

            config = new ConfigFileSettingService(cacheManager, null, null);
        }
Example #2
0
 private ImageConfig(Builder builder)
 {
     CacheMode        = builder.CacheMode;
     MemoryCacheImpl  = builder.MemoryCacheImpl;
     StorageCacheImpl = builder.StorageCacheImpl;
     DecoderTypes     = builder.DecoderTypes;
     UriParser        = builder.UriParser;
 }
        public async Task Set_and_get_example_data_by_passing_specified_key()
        {
            string key            = "exampleKey01";
            byte   data           = 255;
            int    cacheTime      = int.MaxValue;
            var    eventPublisher = new Mock <IMediator>();

            MemoryCacheBase memoryCacheManager = new MemoryCacheBase(new MemoryCache(new MemoryCacheOptions {
            }), eventPublisher.Object);

            await memoryCacheManager.SetAsync(key, data, cacheTime);

            Assert.AreEqual(await memoryCacheManager.GetAsync <byte>(key, async() => { return(await Task.FromResult(new byte())); }), data);
        }
Example #4
0
        public async Task RemoveByPatternTest()
        {
            /*
             * In this test I provide:
             *  1. pattern that consists of "key100\d" which matchs to: key1009, but not to key1010
             *  2. ICacheManager object with several keys
             *  3. List<string> with several keys
             */
            var eventPublisher = new Mock <IMediator>();

            ICacheBase icacheManager = new MemoryCacheBase(new MemoryCache(new MemoryCacheOptions {
            }), eventPublisher.Object);
            await icacheManager.SetAsync("key1001", 33, int.MaxValue);

            await icacheManager.SetAsync("key1202", 1244, int.MaxValue);

            await icacheManager.SetAsync("key1003", 512, int.MaxValue);

            await icacheManager.SetAsync("key1204", 55, int.MaxValue);

            await icacheManager.SetAsync("key1005", 32, int.MaxValue);

            string pattern = @"key100\d"; //"key100" and one digit

            List <string> keys = new List <string>();

            keys.Add("key1001");
            keys.Add("key1202");
            keys.Add("key1003");
            keys.Add("key1204");
            keys.Add("key1005");

            await icacheManager.RemoveByPrefix(pattern);

            Assert.IsNotNull(icacheManager.GetAsync <int>("key1202", async() => { return(await Task.FromResult(0)); }));
            Assert.IsNotNull(icacheManager.GetAsync <int>("key1204", async() => { return(await Task.FromResult(0)); }));
        }