The default implementation of ICacheStoreProvider using private dictionaries
상속: ICacheStoreProvider, IDisposable
 public void GetAsyncCacheStore_should_return_null_if_storeId_less_than_0_or_not_found()
 {
     var provider = new DefaultCacheStoreProvider();
     Assert.IsNull(provider.GetAsyncCacheStore(-1));
     Assert.IsNull(provider.GetAsyncCacheStore(1));
     Assert.IsNotNull(provider.GetAsyncCacheStore(0));
 }
 public void GetAsyncCacheStore_should_return_async_store_adaptor_if_sync_store_with_same_id_found()
 {
     var store = Substitute.For<ICacheStore>();
     store.StoreId.Returns(10);
     var provider = new DefaultCacheStoreProvider();
     provider.RegisterStore(store);
     Assert.IsNotNull(provider.GetAsyncCacheStore(10));
 }
 public void RegisterAsyncStore_should_register_both_type_and_id()
 {
     var store = Substitute.For<IAsyncCacheStore>();
     store.StoreId.Returns(10);
     var provider = new DefaultCacheStoreProvider();
     Assert.Throws<ArgumentNullException>(() => provider.RegisterAsyncStore(null));
     provider.RegisterAsyncStore(store);
     Assert.IsNotNull(provider.GetAsyncCacheStore(10));
     Assert.IsNotNull(provider.GetAsyncCacheStore(store.GetType()));
 }
        public void RegisterStore_should_throw_exception_if_duplicated_async_store_id()
        {
            var store = Substitute.For<ICacheStore>();
            store.StoreId.Returns(10);

            var asyncStore = Substitute.For<IAsyncCacheStore>();
            asyncStore.StoreId.Returns(10);
            var provider = new DefaultCacheStoreProvider();
            provider.RegisterAsyncStore(asyncStore);
            Assert.Throws<InvalidOperationException>(() => provider.RegisterStore(store));
        }
예제 #5
0
        static Global()
        {
            Cache = new MethodInfoCache();

            ContextProvider = new EmptyContextProvider();
            CacheStrategyProvider = new DefaultCacheStrategyProvider();
            AttributeProvider = new DefaulAttributeProvider();
            HashCodeGeneratorProvider = new DefaultHashCodeGeneratorProvider();
            CacheKeyProvider = new DefaultCacheKeyProvider(HashCodeGeneratorProvider);
            CacheStoreProvider = new DefaultCacheStoreProvider();
            ServiceActivator = new ServiceActivator();
            Logger = new NullLogger();
        }
예제 #6
0
        internal static void Init()
        {
            Cache = new MethodInfoCache();

            ContextProvider = new EmptyContextProvider();
            CacheStrategyProvider = new DefaultCacheStrategyProvider();
            AttributeProvider = new DefaulAttributeProvider();
            HashCodeGeneratorProvider = new DefaultHashCodeGeneratorProvider();
            CacheKeyProvider = new DefaultCacheKeyProvider(HashCodeGeneratorProvider);
            CacheStoreProvider = new DefaultCacheStoreProvider();
            ServiceActivator = new DefaultServiceActivator();
            Logger = new NullLogger();
            BackgroundTaskManager = new DefaultBackgroundTaskManager();

            var configFolder = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            CacheProfileProvider = new YamlCacheProfileProvider(Path.Combine(configFolder ?? "", "cacheProfile.yaml"));
        }
 public void GetAsyncCacheStore_should_throw_exception_if_store_type_not_found()
 {
     var provider = new DefaultCacheStoreProvider();
     Assert.Throws<KeyNotFoundException>(() => provider.GetAsyncCacheStore(typeof(DefaultCacheStoreProviderTests)));
     Assert.IsNotNull(provider.GetCacheStore(typeof(IAsyncCacheStore)));
 }
 public void Dispose_should_clear_all_cached_stores()
 {
     var provider = new DefaultCacheStoreProvider();
     provider.Dispose();
     Assert.IsNull(provider.GetCacheStore(0));
     Assert.IsNull(provider.GetAsyncCacheStore(0));
 }