Exemple #1
0
        public void RegisterStore_should_register_both_type_and_id()
        {
            var store = Substitute.For <ICacheStore>();

            store.StoreId.Returns(10);
            var provider = new DefaultCacheStoreProvider();

            Assert.Throws <ArgumentNullException>(() => provider.RegisterStore(null));
            provider.RegisterStore(store);
            Assert.IsNotNull(provider.GetCacheStore(10));
            Assert.IsNotNull(provider.GetCacheStore(store.GetType()));
        }
Exemple #2
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));
        }
Exemple #3
0
        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));
        }