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); }
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)); }
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); }
public void TearDown() { // reset any defaults thay may have been tampered with during a test CacheDecoratorOptions.Default = _originalDecoratorDefaults; GlobalCacheProvider.ResetDefaultConstructors(); }
public void SetUp() { _cacheProvider = new GlobalCacheProvider(); _originalDecoratorDefaults = CacheDecoratorOptions.Default; }