Exemplo n.º 1
0
        public void Cfg_Valid_CfgFile_EnabledStatsAndPerformanceCounters()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "ExpirationVariances";

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            // assert
            cache.CacheHandles.Select(p => p.Configuration.EnableStatistics)
            .Should().AllBeEquivalentTo(true);
            cache.CacheHandles.Select(p => p.Configuration.EnablePerformanceCounters)
            .Should().AllBeEquivalentTo(true);
        }
Exemplo n.º 2
0
        public void Cfg_Valid_CfgFile_EnabledStatsPerformanceCountersDefaults()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "DefaultSysMemCache";

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            // assert
            cache.CacheHandles.Select(p => p.Configuration.EnableStatistics)
            .ShouldAllBeEquivalentTo(Enumerable.Repeat(true, cache.CacheHandles.Count()));
            cache.CacheHandles.Select(p => p.Configuration.EnablePerformanceCounters)
            .ShouldAllBeEquivalentTo(Enumerable.Repeat(false, cache.CacheHandles.Count()));
        }
Exemplo n.º 3
0
        public void Cfg_Valid_AppConfig_ByName()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/app.config");
            string cacheName = "C1";

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            // assert
            cache.Configuration.UpdateMode.Should().Be(CacheUpdateMode.Up);
            cache.CacheHandles.Count().Should().Be(3);
            AssertCacheHandleConfig(cache.CacheHandles.ElementAt(0), "h1", ExpirationMode.None, new TimeSpan(0, 0, 50));
            AssertCacheHandleConfig(cache.CacheHandles.ElementAt(1), "h2", ExpirationMode.Absolute, new TimeSpan(0, 20, 0));
            AssertCacheHandleConfig(cache.CacheHandles.ElementAt(2), "h3", ExpirationMode.Sliding, new TimeSpan(20, 0, 0));
        }
Exemplo n.º 4
0
        public void Cfg_Valid_CfgFile_AllDefaults()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "onlyDefaultsCache";

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <string>(cfg);

            // assert
            cache.Configuration.UpdateMode.Should().Be(CacheUpdateMode.Up);
            cache.Configuration.SerializerType.Should().BeNull();
            cache.Configuration.LoggerFactoryType.Should().BeNull();
            cache.Configuration.BackplaneType.Should().BeNull();
            cache.Configuration.RetryTimeout.Should().Be(100);
            cache.Configuration.MaxRetries.Should().Be(50);
            cache.CacheHandles.Count().Should().Be(1);
            AssertCacheHandleConfig(cache.CacheHandles.ElementAt(0), "defaultsHandle", ExpirationMode.None, TimeSpan.Zero);
        }
Exemplo n.º 5
0
        public void Redis_Valid_CfgFile_LoadWithConnectionString()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "redisConfigFromConnectionString";

            // have to load the configuration manually because the file is not avialbale to the default ConfigurtaionManager
            RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName);
            var redisConfig = RedisConfigurations.GetConfiguration("redisConnectionString");

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            // assert
            cache.CacheHandles.Any(p => p.Configuration.IsBackplaneSource).Should().BeTrue();

            // database is the only option apart from key and connection string which must be set, database will not be set through connection string
            // to define which database should actually be used...
            redisConfig.Database.Should().Be(131);
        }
Exemplo n.º 6
0
        public void Cfg_Valid_CfgFile_DefaultSysMemCache()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "DefaultSysMemCache";

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            var memHandle = cache.CacheHandles.ElementAt(0) as MemoryCacheHandle <object>;

            memHandle.CacheSettings.Get(0).Should().Be("42");
            memHandle.CacheSettings.Get(1).Should().Be("69");
            memHandle.CacheSettings.Get(2).Should().Be("00:10:00");

            // assert
            cache.Configuration.UpdateMode.Should().Be(CacheUpdateMode.None);
            cache.CacheHandles.Count().Should().Be(1);
            AssertCacheHandleConfig(cache.CacheHandles.ElementAt(0), "default", ExpirationMode.Sliding, new TimeSpan(0, 5, 0));
        }
Exemplo n.º 7
0
        public void Redis_Valid_CfgFile_LoadWithRedisBackplane()
        {
            // arrange
            string fileName  = TestConfigurationHelper.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config");
            string cacheName = "redisConfigFromConfig";

            // have to load the configuration manually because the file is not avialbale to the default ConfigurtaionManager
            RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName);
            var redisConfig = RedisConfigurations.GetConfiguration("redisFromCfgConfigurationId");

            // act
            var cfg   = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName);
            var cache = CacheFactory.FromConfiguration <object>(cfg);

            // assert
            cache.CacheHandles.Any(p => p.Configuration.IsBackplaneSource).Should().BeTrue();

            redisConfig.Database.Should().Be(113);
            redisConfig.ConnectionTimeout.Should().Be(1200);
            redisConfig.AllowAdmin.Should().BeTrue();
            redisConfig.KeyspaceNotificationsEnabled.Should().BeTrue();
        }