Beispiel #1
0
        public void BuildConnectionString_WithDefaultConnectionParameters_ShouldReturnExpectedDataSourceString()
        {
            var overridedConfig = new Dictionary <string, string>
            {
                { "database:servicename", "service" },
                { "database:hostname", "host" }
            };

            var dbConfig = GetDbConfig(overridedConfig);

            var expectedDataSource = OracleConnectionStringBuilder.GetDefaultDataSource("host", dbConfig.Port, "service");

            var adminPrivilegeses = new[] { false, true };

            foreach (var adminPrivileges in adminPrivilegeses)
            {
                using (var connection = dbConfig.GetDbProviderFactory(adminPrivileges).CreateConnection())
                {
                    connection.DataSource.Should().Be(expectedDataSource);
                }
            }
        }
Beispiel #2
0
        public void VerifyOracleConnectionOpen_WithDecriptionDatasourceWithoutHostNameAndServiceNameIsValidTnsAliasName_VerifyThatConnectionFails()
        {
            var overridedConfig = new Dictionary <string, string>
            {
                { "database:serviceName", BaseConfig.InContainer ? "TNSTEST_INDOCKER" : "TNSTEST" },
            };

            var dbConfig           = GetDbConfig(overridedConfig);
            var expectedDataSource = OracleConnectionStringBuilder.GetDefaultDataSource(dbConfig.Hostname, dbConfig.Port, dbConfig.DatabaseName);

            var connectionString = OracleConnectionStringBuilder.BuildConnectionString(dbConfig, expectedDataSource, true);

            Action action = () =>
            {
                using (var connection = new OracleConnection(connectionString))
                {
                    connection.SafeOpen();
                }
            };

            // ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
            action.Should().Throw <OracleException>().Which.Number.Should().Be(12514);
        }