예제 #1
0
        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));
        }
예제 #2
0
        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()));
        }
예제 #3
0
        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)));
        }
예제 #4
0
        public void Dispose_should_clear_all_cached_stores()
        {
            var provider = new DefaultCacheStoreProvider();

            provider.Dispose();
            Assert.IsNull(provider.GetCacheStore(0));
            Assert.IsNull(provider.GetAsyncCacheStore(0));
        }
예제 #5
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));
        }