public void Redis_Configurations_LoadWithConnectionString() { string fileName = BaseCacheManagerTest.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config"); RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName); var cfg = RedisConfigurations.GetConfiguration("redisConnectionString"); cfg.ConnectionString.Should().Be("127.0.0.1:6379,allowAdmin=true,ssl=true"); }
public void Redis_Valid_CfgFile_LoadWithRedisBackPlate() { // arrange string fileName = BaseCacheManagerTest.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config"); string cacheName = "redisWithBackPlate"; // act var cfg = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName); var cache = CacheFactory.FromConfiguration <object>(cacheName, cfg); // assert cache.CacheHandles.Any(p => p.Configuration.IsBackPlateSource).Should().BeTrue(); }
public void Redis_Multiple_PubSub_Change() { // arrange string fileName = BaseCacheManagerTest.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config"); var channelName = Guid.NewGuid().ToString(); // redis config name must be same for all cache handles, configured via file and via code // otherwise the pub sub channel name is different string cacheName = "redisConfigFromConfig"; RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName); var cfg = (CacheManagerConfiguration)ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName); cfg.BackplaneChannelName = channelName; var cfgCache = CacheFactory.FromConfiguration <object>(cfg); var item = new CacheItem <object>(Guid.NewGuid().ToString(), "something"); // act/assert RedisTests.RunMultipleCaches( (cacheA, cacheB) => { cacheA.Put(item); cacheA.Get(item.Key).Should().Be("something"); Thread.Sleep(10); var value = cacheB.Get(item.Key); value.Should().Be(item.Value, cacheB.ToString()); cacheB.Put(item.Key, "new value"); }, (cache) => { int tries = 0; object value = null; do { tries++; Thread.Sleep(100); value = cache.Get(item.Key); }while (value.ToString() != "new value" && tries < 10); value.Should().Be("new value", cache.ToString()); }, 1, TestManagers.CreateRedisAndDicCacheWithBackplane(113, true, channelName, Serializer.Json), cfgCache, TestManagers.CreateRedisCache(113, false, Serializer.Json), TestManagers.CreateRedisAndDicCacheWithBackplane(113, true, channelName, Serializer.Json)); }
public void Redis_Valid_CfgFile_LoadWithRedisBackPlate() { // arrange string fileName = BaseCacheManagerTest.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config"); string cacheName = "redisConfig"; // have to load the configuration manually because the file is not avialbale to the default ConfigurtaionManager RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName); // act var cfg = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName); var cache = CacheFactory.FromConfiguration <object>(cfg); // assert cache.CacheHandles.Any(p => p.Configuration.IsBackPlateSource).Should().BeTrue(); }
////[Trait("category", "Unreliable")] public void Redis_Multiple_PubSub_Change() { // arrange string fileName = BaseCacheManagerTest.GetCfgFileName(@"/Configuration/configuration.valid.allFeatures.config"); var channelName = Guid.NewGuid().ToString(); // redis config name must be same for all cache handles, configured via file and via code // otherwise the pub sub channel name is different string cacheName = "redisConfig"; RedisConfigurations.LoadConfiguration(fileName, RedisConfigurationSection.DefaultSectionName); var cfg = ConfigurationBuilder.LoadConfigurationFile(fileName, cacheName); cfg.BackPlateChannelName = channelName; var cfgCache = CacheFactory.FromConfiguration <object>(cfg); var item = new CacheItem <object>(Guid.NewGuid().ToString(), "something"); // act/assert RedisTests.RunMultipleCaches( (cacheA, cacheB) => { cacheA.Put(item); Thread.Sleep(10); var value = cacheB.Get(item.Key); value.Should().Be(item.Value, cacheB.ToString()); cacheB.Put(item.Key, "new value"); }, (cache) => { Thread.Sleep(12); var value = cache.Get(item.Key); value.Should().Be("new value", cache.ToString()); }, 2, TestManagers.CreateRedisAndSystemCacheWithBackPlate(69, true, channelName), cfgCache, TestManagers.CreateRedisCache(69), TestManagers.CreateRedisAndSystemCacheWithBackPlate(69, true, channelName)); }
public void Redis_Valid_CfgFile_LoadWithConnectionString() { // arrange string fileName = BaseCacheManagerTest.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); }