Exemple #1
0
        public void ConnectionString_Overridden_By_CloudFoundryConfig()
        {
            // arrange
            // simulate an appsettings file
            var appsettings = new Dictionary <string, string>()
            {
                ["redis:client:ConnectionString"] = "Server=fake;Database=test;Uid=steeltoe;Pwd=password;"
            };

            // add environment variables as Cloud Foundry would
            Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION);
            Environment.SetEnvironmentVariable("VCAP_SERVICES", RedisCacheTestHelpers.SingleServerVCAP);

            // add settings to config
            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddInMemoryCollection(appsettings);
            configurationBuilder.AddEnvironmentVariables();
            configurationBuilder.AddCloudFoundry();
            var config = configurationBuilder.Build();

            // act
            var sconfig = new RedisCacheConnectorOptions(config);

            // assert
            Assert.NotEqual(appsettings["redis:client:ConnectionString"], sconfig.ToString());
        }
Exemple #2
0
        public void ConnectionString_Returned_AsConfigured()
        {
            var appsettings = new Dictionary <string, string>()
            {
                ["redis:client:ConnectionString"] = "Server=fake;Database=test;Uid=steeltoe;Pwd=password;"
            };
            var configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.AddInMemoryCollection(appsettings);
            var config = configurationBuilder.Build();

            var sconfig = new RedisCacheConnectorOptions(config);

            Assert.Equal(appsettings["redis:client:ConnectionString"], sconfig.ToString());
        }
Exemple #3
0
        public void UpdateOptions_FromServiceInfo_ReturnsExcpected()
        {
            var configurer  = new RedisCacheConfigurer();
            var connOptions = new RedisCacheConnectorOptions();
            var si          = new RedisServiceInfo("myId", RedisServiceInfo.REDIS_SCHEME, "foobar", 4321, "sipassword");

            configurer.UpdateOptions(si, connOptions);

            Assert.Equal("foobar:4321,password=sipassword,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", connOptions.ToString());
            Assert.Null(connOptions.InstanceName);
        }
        public void UpdateOptions_FromServiceInfo_ReturnsExcpected()
        {
            RedisCacheConfigurer       configurer  = new RedisCacheConfigurer();
            RedisCacheConnectorOptions connOptions = new RedisCacheConnectorOptions();
            RedisServiceInfo           si          = new RedisServiceInfo("myId", "foobar", 4321, "sipassword");

            si.ApplicationInfo = new ApplicationInstanceInfo()
            {
                ApplicationId = "applicationId"
            };
            configurer.UpdateOptions(si, connOptions);

            Assert.Equal("foobar:4321,password=sipassword,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", connOptions.ToString());
            Assert.Null(connOptions.InstanceId);
        }