public void GetCacheStore_should_return_default_cache_store_if_not_found()
        {
            var invocation = Substitute.For <_IInvocation>();
            var context    = new Dictionary <string, object>
            {
                [Global.__flatwhite_outputcache_attribute] = new OutputCacheAttribute
                {
                    CacheStoreId   = 100,
                    CacheStoreType = Substitute.For <ICacheStore>().GetType()
                }
            };
            var cacheStoreProvider = Substitute.For <ICacheStoreProvider>();

            cacheStoreProvider.GetCacheStore(Arg.Is <int>(i => i > 0)).Returns((ICacheStore)null);
            cacheStoreProvider.GetCacheStore(Arg.Any <Type>()).Returns((ICacheStore)null);
            Global.CacheStoreProvider = cacheStoreProvider;

            var stg = new DefaultCacheStrategy();

            // Action
            var store = stg.GetCacheStore(invocation, context);

            // Assert
            cacheStoreProvider.Received(1).GetCacheStore(0);
        }
        public void GetCacheStore_should_return_default_cache_store_if_id_not_found()
        {
            var invocation = Substitute.For <_IInvocation>();
            var context    = new Dictionary <string, object>
            {
                [Global.__flatwhite_outputcache_attribute] = new OutputCacheAttribute
                {
                    CacheStoreId = 100
                }
            };
            var cacheStoreProvider = Substitute.For <ICacheStoreProvider>();

            cacheStoreProvider.When(x => x.GetCacheStore(100)).Do(x => { throw new KeyNotFoundException(); });
            Global.CacheStoreProvider = cacheStoreProvider;

            var stg = new DefaultCacheStrategy();

            // Action
            var store = stg.GetCacheStore(invocation, context);

            // Assert
            cacheStoreProvider.Received(1).GetCacheStore(0);
        }
        public void GetCacheStore_should_try_to_get_cache_store_by_provided_type()
        {
            var invocation = Substitute.For <_IInvocation>();
            var context    = new Dictionary <string, object>
            {
                [Global.__flatwhite_outputcache_attribute] = new OutputCacheAttribute
                {
                    CacheStoreId   = 100,
                    CacheStoreType = Substitute.For <ICacheStore>().GetType()
                }
            };
            var cacheStoreProvider = Substitute.For <ICacheStoreProvider>();

            cacheStoreProvider.GetCacheStore(100).Returns((ICacheStore)null);
            Global.CacheStoreProvider = cacheStoreProvider;

            var stg = new DefaultCacheStrategy();

            // Action
            var store = stg.GetCacheStore(invocation, context);

            // Assert
            cacheStoreProvider.Received(1).GetCacheStore(Arg.Is <Type>(t => t == Substitute.For <ICacheStore>().GetType()));
        }