Ejemplo n.º 1
0
        public void GetCache_ReturnCurrentCache()
        {
            IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>();

            configCache.Stub(x => x.GetCachedValue("MyCachedConfigKey")).Return("MyCachedConfigValue");
            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");
            string       result = sut.GetConfigValue("MyCachedConfigKey");
            IConfigCache cache  = sut.Cache;

            Assert.IsNotNull(cache);
        }
Ejemplo n.º 2
0
        public void IfCacheSpecified_WillUseCachedValueIfPresent()
        {
            IConfigCache configCache = MockRepository.GenerateStub <IConfigCache>();

            configCache.Stub(x => x.GetCachedValue("MyCachedConfigKey")).Return("MyCachedConfigValue");
            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");
            string result = sut.GetConfigValue("MyCachedConfigKey");

            Assert.That(result.Equals("MyCachedConfigValue", StringComparison.InvariantCulture));
        }