Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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")));
        }