コード例 #1
0
        public void WhenConfiguredWithCacheAdministrator_Get_ShouldRegisterCache()
        {
            // given
            var cacheProvider = new GlobalCacheProvider {
                CacheAdministator = new CacheAdministator()
            };

            // when
            ICache cache = cacheProvider.Get <ICache>("SomeCacheName");

            // then
            Assert.That(cacheProvider.CacheAdministator.Contains(cache), Is.True);
        }
コード例 #2
0
        public void WhenConfiguredWithCacheAdministrator_Get_ShouldNotTryAndRegisterCacheTwice()
        {
            // given
            var cacheProvider = new GlobalCacheProvider {
                CacheAdministator = new CacheAdministator()
            };

            cacheProvider.Get <ICache>("SomeCacheName");

            // when
            cacheProvider.Get <ICache>("SomeCacheName");

            // then
            Assert.That(cacheProvider.CacheAdministator.AllCaches.Count(), Is.EqualTo(1));
        }
コード例 #3
0
        public void DefaultInstance_WhenFirstCalled_ShouldBeConfiguredWithRegisteredDefaultCacheConstructors()
        {
            // given
            var cacheProvider = GlobalCacheProvider.DefaultInstance;

            // when
            // overwrite the default cache contructor for ICache
            // - this will be ignored by cacheProvider as it was registered after cacheProvider
            //   was created
            GlobalCacheProvider.RegisterDefaultConstructor <ICache>(id => NullCache.Instance);

            ICache cache = cacheProvider.Get <ICache>("MyNewCache");

            // then
            Assert.That(cache.As <INullCache>() == null, Is.True);
        }
コード例 #4
0
 public void TearDown()
 {
     // reset any defaults thay may have been tampered with during a test
     CacheDecoratorOptions.Default = _originalDecoratorDefaults;
     GlobalCacheProvider.ResetDefaultConstructors();
 }
コード例 #5
0
 public void SetUp()
 {
     _cacheProvider             = new GlobalCacheProvider();
     _originalDecoratorDefaults = CacheDecoratorOptions.Default;
 }