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;
        }
Exemplo n.º 3
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);
        }