예제 #1
0
        public void ConfigureConnection_NoServiceInfo_ReturnsExpected()
        {
            // arrange
            var configurer = new RedisCacheConfigurer();
            var config     = new RedisCacheConnectorOptions()
            {
                Host     = "localhost",
                Port     = 1234,
                Password = "******"
            };

            // act
            var opts = configurer.Configure(null, config);

            Assert.NotNull(opts);

            // assert
            Assert.NotNull(((ConfigurationOptions)opts.ToStackExchangeObject(typeof(ConfigurationOptions))).EndPoints);
            var ep = ((ConfigurationOptions)opts.ToStackExchangeObject(typeof(ConfigurationOptions))).EndPoints[0] as DnsEndPoint;

            Assert.NotNull(ep);
            Assert.Equal("localhost", ep.Host);
            Assert.Equal(1234, ep.Port);
            Assert.Equal("password", opts.Password);
        }
예제 #2
0
        public void ConfigureConnection_ServiceInfoOveridesConfig_ReturnsExpected()
        {
            // arrange
            var configurer = new RedisCacheConfigurer();
            var config     = new RedisCacheConnectorOptions()
            {
                Host     = "localhost",
                Port     = 1234,
                Password = "******"
            };
            var si = new RedisServiceInfo("myId", RedisServiceInfo.REDIS_SCHEME, "foobar", 4321, "sipassword");

            // act
            var opts = configurer.Configure(si, config);

            Assert.NotNull(opts);

            // assert
            Assert.NotNull(((ConfigurationOptions)opts.ToStackExchangeObject(typeof(ConfigurationOptions))).EndPoints);
            var ep = ((ConfigurationOptions)opts.ToStackExchangeObject(typeof(ConfigurationOptions))).EndPoints[0] as DnsEndPoint;

            Assert.NotNull(ep);
            Assert.Equal("foobar", ep.Host);
            Assert.Equal(4321, ep.Port);
            Assert.Equal("sipassword", opts.Password);
        }
예제 #3
0
        public void ConfigureConnection_ServiceInfoOveridesConfig_ReturnsExpected()
        {
            RedisCacheConfigurer       configurer = new RedisCacheConfigurer();
            RedisCacheConnectorOptions config     = new RedisCacheConnectorOptions()
            {
                Host     = "localhost",
                Port     = 1234,
                Password = "******"
            };
            RedisServiceInfo si = new RedisServiceInfo("myId", "foobar", 4321, "sipassword");

            si.ApplicationInfo = new ApplicationInstanceInfo()
            {
                InstanceId = "instanceId"
            };
            var opts = configurer.ConfigureConnection(si, config);

            Assert.NotNull(opts);

            Assert.NotNull(opts.EndPoints);
            var ep = opts.EndPoints[0] as DnsEndPoint;

            Assert.NotNull(ep);
            Assert.Equal("foobar", ep.Host);
            Assert.Equal(4321, ep.Port);
            Assert.Equal("sipassword", opts.Password);
        }
예제 #4
0
        public void Configure_ServiceInfoOveridesConfig_ReturnsExpected()
        {
            RedisCacheConfigurer       configurer = new RedisCacheConfigurer();
            RedisCacheConnectorOptions config     = new RedisCacheConnectorOptions()
            {
                Host       = "localhost",
                Port       = 1234,
                Password   = "******",
                InstanceId = "instanceId"
            };
            RedisServiceInfo si = new RedisServiceInfo("myId", "foobar", 4321, "sipassword");

            si.ApplicationInfo = new ApplicationInstanceInfo()
            {
                InstanceId = "instanceId"
            };
            var opts = configurer.Configure(si, config);

            Assert.NotNull(opts);
            var redisOptions = opts.Value;

            Assert.NotNull(redisOptions);

            Assert.Equal("foobar:4321,password=sipassword,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #5
0
        public string GetConnectionString()
        {
            var info        = configuration.GetSingletonServiceInfo <RedisServiceInfo>();
            var redisConfig = new RedisCacheConnectorOptions(configuration);

            var connectionOptions = new RedisCacheConfigurer().Configure(info, redisConfig);

            return(connectionOptions.ToString());
        }
예제 #6
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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        public void UpdateOptions_FromConfig_WithConnectionString_ReturnsExcpected()
        {
            RedisCacheConfigurer       configurer   = new RedisCacheConfigurer();
            RedisCacheOptions          redisOptions = new RedisCacheOptions();
            RedisCacheConnectorOptions config       = new RedisCacheConnectorOptions()
            {
                ConnectionString = "foobar",
                InstanceId       = "instanceId"
            };

            configurer.UpdateOptions(config, redisOptions);

            Assert.Equal("foobar", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #9
0
        public void UpdateOptions_FromServiceInfo_ReturnsExcpected()
        {
            RedisCacheConfigurer configurer   = new RedisCacheConfigurer();
            RedisCacheOptions    redisOptions = new RedisCacheOptions();
            RedisServiceInfo     si           = new RedisServiceInfo("myId", "foobar", 4321, "sipassword");

            si.ApplicationInfo = new ApplicationInstanceInfo()
            {
                InstanceId = "instanceId"
            };
            configurer.UpdateOptions(si, redisOptions);

            Assert.Equal("foobar:4321,password=sipassword", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #10
0
        public void UpdateOptions_FromConfig_WithOutConnectionString_ReturnsExcpected()
        {
            RedisCacheConfigurer       configurer   = new RedisCacheConfigurer();
            RedisCacheOptions          redisOptions = new RedisCacheOptions();
            RedisCacheConnectorOptions config       = new RedisCacheConnectorOptions()
            {
                Host       = "localhost",
                Port       = 1234,
                Password   = "******",
                InstanceId = "instanceId"
            };

            configurer.UpdateOptions(config, redisOptions);

            Assert.Equal("localhost:1234,password=password,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #11
0
        public void Configure_ServiceInfoOveridesConfig_ReturnsExpected()
        {
            var configurer = new RedisCacheConfigurer();
            var config     = new RedisCacheConnectorOptions()
            {
                Host         = "localhost",
                Port         = 1234,
                Password     = "******",
                InstanceName = "instanceId"
            };
            var si = new RedisServiceInfo("myId", RedisServiceInfo.REDIS_SCHEME, "foobar", 4321, "sipassword");
            var connectionSettings = configurer.Configure(si, config);

            Assert.NotNull(connectionSettings);

            Assert.Equal("foobar:4321,password=sipassword,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", connectionSettings.ToString());
            Assert.Equal("instanceId", connectionSettings.InstanceName);
        }
예제 #12
0
        public void Configure_NoServiceInfo_ReturnsExpected()
        {
            var configurer = new RedisCacheConfigurer();
            var config     = new RedisCacheConnectorOptions()
            {
                Host         = "localhost",
                Port         = 1234,
                Password     = "******",
                InstanceName = "instanceId"
            };
            var opts = configurer.Configure(null, config);

            Assert.NotNull(opts);
            var redisOptions = (RedisCacheOptions)opts.ToMicrosoftExtensionObject(typeof(RedisCacheOptions));

            Assert.NotNull(redisOptions);

            Assert.Equal("localhost:1234,password=password,allowAdmin=false,abortConnect=true,resolveDns=false,ssl=false", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #13
0
        public void Configure_NoServiceInfo_ReturnsExpected()
        {
            RedisCacheConfigurer    configurer = new RedisCacheConfigurer();
            RedisCacheConfiguration config     = new RedisCacheConfiguration()
            {
                Host       = "localhost",
                Port       = 1234,
                Password   = "******",
                InstanceId = "instanceId"
            };
            var opts = configurer.Configure(null, config);

            Assert.NotNull(opts);
            var redisOptions = opts.Value;

            Assert.NotNull(redisOptions);

            Assert.Equal("localhost:1234,password=password", redisOptions.Configuration);
            Assert.Equal("instanceId", redisOptions.InstanceName);
        }
예제 #14
0
        public void ConfigureConnection_NoServiceInfo_ReturnsExpected()
        {
            RedisCacheConfigurer       configurer = new RedisCacheConfigurer();
            RedisCacheConnectorOptions config     = new RedisCacheConnectorOptions()
            {
                Host     = "localhost",
                Port     = 1234,
                Password = "******"
            };
            var opts = configurer.ConfigureConnection(null, config);

            Assert.NotNull(opts);

            Assert.NotNull(opts.EndPoints);
            var ep = opts.EndPoints[0] as DnsEndPoint;

            Assert.NotNull(ep);
            Assert.Equal("localhost", ep.Host);
            Assert.Equal(1234, ep.Port);
            Assert.Equal("password", opts.Password);
        }