Exemple #1
0
        public Connection Get(IConfiguration configuration, string serviceName)
        {
            var info = serviceName == null
              ? configuration.GetSingletonServiceInfo <MySqlServiceInfo>()
              : configuration.GetRequiredServiceInfo <MySqlServiceInfo>(serviceName);

            var mySqlConfig = new MySqlProviderConnectorOptions(configuration);
            var configurer  = new MySqlProviderConfigurer();
            var connString  = configurer.Configure(info, mySqlConfig);

            return(new Connection
            {
                ConnectionString = connString,
                Name = "MySql" + serviceName?.Insert(0, "-")
            });
        }
Exemple #2
0
        public void Configure_NoServiceInfo_ReturnsExpected()
        {
            MySqlProviderConnectorOptions config = new MySqlProviderConnectorOptions()
            {
                Server   = "localhost",
                Port     = 1234,
                Username = "******",
                Password = "******",
                Database = "database"
            };

            MySqlProviderConfigurer configurer = new MySqlProviderConfigurer();
            var opts = configurer.Configure(null, config);

            Assert.Contains("Server=localhost;", opts);
            Assert.Contains("Port=1234;", opts);
            Assert.Contains("Username=username;", opts);
            Assert.Contains("Password=password;", opts);
            Assert.Contains("Database=database;", opts);
        }
Exemple #3
0
        public void UpdateConfiguration_WithMySqlServiceInfo_ReturnsExpected()
        {
            MySqlProviderConfigurer       configurer = new MySqlProviderConfigurer();
            MySqlProviderConnectorOptions config     = new MySqlProviderConnectorOptions()
            {
                Server   = "localhost",
                Port     = 1234,
                Username = "******",
                Password = "******",
                Database = "database"
            };
            MySqlServiceInfo si = new MySqlServiceInfo("MyId", "mysql://*****:*****@192.168.0.90:3306/cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355");

            configurer.UpdateConfiguration(si, config);

            Assert.Equal("192.168.0.90", config.Server);
            Assert.Equal(3306, config.Port);
            Assert.Equal("Dd6O1BPXUHdrmzbP", config.Username);
            Assert.Equal("7E1LxXnlH2hhlPVt", config.Password);
            Assert.Equal("cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355", config.Database);
        }
Exemple #4
0
        public void UpdateConfiguration_WithNullMySqlServiceInfo_ReturnsExpected()
        {
            MySqlProviderConfigurer       configurer = new MySqlProviderConfigurer();
            MySqlProviderConnectorOptions config     = new MySqlProviderConnectorOptions()
            {
                Server   = "localhost",
                Port     = 1234,
                Username = "******",
                Password = "******",
                Database = "database"
            };

            configurer.UpdateConfiguration(null, config);

            Assert.Equal("localhost", config.Server);
            Assert.Equal(1234, config.Port);
            Assert.Equal("username", config.Username);
            Assert.Equal("password", config.Password);
            Assert.Equal("database", config.Database);
            Assert.Null(config.ConnectionString);
        }
Exemple #5
0
        public void Configure_ServiceInfoOveridesConfig_ReturnsExpected()
        {
            MySqlProviderConnectorOptions config = new MySqlProviderConnectorOptions()
            {
                Server   = "localhost",
                Port     = 1234,
                Username = "******",
                Password = "******",
                Database = "database"
            };

            MySqlProviderConfigurer configurer = new MySqlProviderConfigurer();
            MySqlServiceInfo        si         = new MySqlServiceInfo("MyId", "mysql://*****:*****@192.168.0.90:3306/cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355");

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

            Assert.Contains("Server=192.168.0.90;", opts);
            Assert.Contains("Port=3306;", opts);
            Assert.Contains("Username=Dd6O1BPXUHdrmzbP;", opts);
            Assert.Contains("Password=7E1LxXnlH2hhlPVt;", opts);
            Assert.Contains("Database=cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355;", opts);
        }