Пример #1
0
        public void VerifyOracleConnectionOpen_WhenDatasourcIsSimpleEzConnect_VerifyThatConnectionSucceed()
        {
            var dbConfig           = GetDbConfig();
            var expectedDataSource = dbConfig.Datasource = $"{dbConfig.Hostname}/{dbConfig.DatabaseName}";

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

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

            action.Should().NotThrow();
        }
Пример #2
0
        public void VerifyOracleConnectionOpen_WhenDataSourceIsValidTnsAliasName_VerifyThatConnectionSucceed()
        {
            var overridedConfig = new Dictionary <string, string>
            {
                { "database:dataSource", BaseConfig.InContainer ? "TNSTEST_INDOCKER" : "TNSTEST" },
            };

            var dbConfig           = GetDbConfig(overridedConfig);
            var expectedDataSource = dbConfig.Datasource;

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

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

            action.Should().NotThrow();
        }
Пример #3
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);
        }