public void IfCacheSpecified_ChangingContextClearsCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); configCache.AssertWasNotCalled(x => x.ClearCache()); sut.SetContext(new Dictionary <string, string>()); configCache.AssertWasCalled(x => x.ClearCache()); }
public void IfCacheSpecified_UpsertingConfigValueClearsCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); configCache.AssertWasNotCalled(x => x.ClearCache()); sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); configCache.AssertWasCalled(x => x.ClearCache()); }
public void IfCacheSpecified_AReadResultsInKeyValueWrittenToCache() { IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>(); CacheableConfigController sut = new CacheableConfigController(); sut.Cache = configCache; Queue <string> priority = new Queue <string>(); priority.Enqueue("FirstPlane"); sut.Priority = priority; sut.UpsertDefaultConfigValue("FirstPlane", "ConfigKey", "ConfigValue"); Dictionary <string, string> context = new Dictionary <string, string>(); context.Add("FirstPlane", "MyConfigContext"); sut.SearchContext = context; sut.GetConfigValue("ConfigKey"); configCache.AssertWasCalled(x => x.CacheInsert(Arg <string> .Is.Equal("ConfigKey"), Arg <string> .Is.Equal("ConfigValue"))); }