Exemplo n.º 1
0
        public void should_have_a_field_named_flush_mode()
        {
            var service = new BlendedCache(_contextCacheMock, null, null, null);
            var field = service.GetType().GetField(_flushModePrivateField, BindingFlags.NonPublic | BindingFlags.Instance);

            Assert.NotNull(field, "There is a field required to fully test out the flush mode behavior.");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Will get a blended cache under the default conditions.
        /// </summary>
        /// <returns></returns>
        public static BlendedCache GetCache(IContextCache contextCache = null, IVolatileCache volatileCache = null, ILongTermCache longTermCache = null, IBlendedCacheConfiguration configuration = null, bool initialFlushMode = false)
        {
            if(contextCache == null)
                contextCache = new DictionaryContextCache();
            if(volatileCache == null)
                volatileCache = new DictionaryVolatileCache();
            if(longTermCache == null)
                longTermCache = new DictionaryLongTermCache();
            if(configuration == null)
                configuration = new BlendedCacheConfiguration();

            var cache = new BlendedCache(contextCache, volatileCache, longTermCache, configuration);

            if (initialFlushMode)
                cache.GetType().GetField("_flushMode", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(cache, true);

            return cache;
        }
        private void Execute()
        {
            var cache = new BlendedCache(_contextCacheMock, _volatileCacheMock, _longTermCacheMock, _configurationMock);

            cache.SetService<IContextCacheLookup>(_contextCacheLookupMock);
            cache.SetService<IVolatileCacheLookup>(_volatileCacheLookupMock);
            cache.SetService<ILongTermCacheLookup>(_longTermCacheLookupMock);
            cache.SetService<ICacheKeyConverter>(_cacheKeyConverterMock);

            var cacheItemMetricLookup = RMM.GenerateStrictMock<ICachedItemMetricsLookup>();
            RME.Stub(cacheItemMetricLookup, x => x.GetOrCreateCacheItemMetric<TDataMock, string>(_fixedUpCacheKey, _lookupKey)).Return(_cacheItemMetrics);
            cache.SetService<ICachedItemMetricsLookup>(cacheItemMetricLookup);
            cache.SetService<ICacheSetter>(_cacheSetterMock);

            if(_flushMode.HasValue)
                cache.SetFlushMode(_flushMode.Value);

            _response = cache.Get<TDataMock>(_lookupKey);
        }
Exemplo n.º 4
0
        private void Execute()
        {
            var cached = new BlendedCache(_contextCacheMock, _volatileCacheMock, _longTermCacheMock, _configurationMock);
            cached.SetService<ICacheSetter>(_setterMock);

            _blendedCache = cached;
            _blendedCache.Set(_lookupKey, _cachedItem);
        }
Exemplo n.º 5
0
        private void Execute()
        {
            var service = new BlendedCache(_contextCacheMock, null, null, null);
            service.GetType().GetField(_flushModePrivateField, BindingFlags.NonPublic | BindingFlags.Instance).SetValue(service, _initialFlushMode);

            _response = service.SetFlushMode(_flushMode);
        }