public void Oracle_Is_Connected_Returns_Up_Status()
        {
            var implementationType = OracleTypeLocator.OracleConnection;
            var sqlConfig          = new OracleProviderConnectorOptions();
            var sInfo       = new OracleServiceInfo("MyId", "oracle://*****:*****@localhost:1521/orclpdb1");
            var logrFactory = new LoggerFactory();
            var connFactory = new OracleProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.UP, status.Status);
        }
        public void PostgreSql_Is_Connected_Returns_Up_Status()
        {
            var implementationType = PostgreSqlTypeLocator.NpgsqlConnection;
            var sqlConfig          = new PostgresProviderConnectorOptions();
            var sInfo       = new PostgresServiceInfo("MyId", "postgres://*****:*****@localhost:5432/postgres");
            var logrFactory = new LoggerFactory();
            var connFactory = new PostgresProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.UP, status.Status);
        }
        public void MySql_Is_Connected_Returns_Up_Status()
        {
            var implementationType = MySqlTypeLocator.MySqlConnection;
            var sqlConfig          = new MySqlProviderConnectorOptions()
            {
                ConnectionTimeout = 1
            };
            var sInfo       = new MySqlServiceInfo("MyId", "mysql://*****:*****@localhost:3306");
            var logrFactory = new LoggerFactory();
            var connFactory = new MySqlProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.UP, status.Status);
        }
        public void Sql_Is_Connected_Returns_Up_Status()
        {
            var implementationType = SqlServerTypeLocator.SqlConnection;
            var sqlConfig          = new SqlServerProviderConnectorOptions()
            {
                Timeout = 1, ConnectionString = "Server=(localdb)\\MSSQLLocalDB;Integrated Security=true"
            };
            var sInfo       = new SqlServerServiceInfo("MyId", string.Empty);
            var logrFactory = new LoggerFactory();
            var connFactory = new SqlServerProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.UP, status.Status);
        }
        public void Oracle_Not_Connected_Returns_Down_Status()
        {
            var implementationType = OracleTypeLocator.OracleConnection;
            var sqlConfig          = new OracleProviderConnectorOptions()
            {
                ConnectionTimeout = 1
            };
            var sInfo       = new OracleServiceInfo("MyId", "oracle://*****:*****@localhost:1521/someService");
            var logrFactory = new LoggerFactory();
            var connFactory = new OracleProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.DOWN, status.Status);
            Assert.Contains(status.Details.Keys, k => k == "error");
        }
        public void PostgreSql_Not_Connected_Returns_Down_Status()
        {
            var implementationType = PostgreSqlTypeLocator.NpgsqlConnection;
            var sqlConfig          = new PostgresProviderConnectorOptions()
            {
                Timeout = 1
            };
            var sInfo       = new PostgresServiceInfo("MyId", "postgres://localhost:5432/cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355");
            var logrFactory = new LoggerFactory();
            var connFactory = new PostgresProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.DOWN, status.Status);
            Assert.Contains(status.Details.Keys, k => k == "error");
        }
        public void MySql_Not_Connected_Returns_Down_Status()
        {
            var implementationType = MySqlTypeLocator.MySqlConnection;
            var sqlConfig          = new MySqlProviderConnectorOptions()
            {
                ConnectionTimeout = 1
            };
            var sInfo       = new MySqlServiceInfo("MyId", "mysql://localhost:80;databaseName=invalidDatabaseName");
            var logrFactory = new LoggerFactory();
            var connFactory = new MySqlProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.DOWN, status.Status);
            Assert.Contains(status.Details.Keys, k => k == "error");
        }
        public void Sql_Not_Connected_Returns_Down_Status()
        {
            var implementationType = SqlServerTypeLocator.SqlConnection;
            var sqlConfig          = new SqlServerProviderConnectorOptions()
            {
                Timeout = 1
            };
            var sInfo       = new SqlServerServiceInfo("MyId", "jdbc:sqlserver://localhost:1433/databaseName=invalidDatabaseName", "Dd6O1BPXUHdrmzbP", "7E1LxXnlH2hhlPVt");
            var logrFactory = new LoggerFactory();
            var connFactory = new SqlServerProviderConnectorFactory(sInfo, sqlConfig, implementationType);
            var h           = new RelationalDbHealthContributor((IDbConnection)connFactory.Create(null), logrFactory.CreateLogger <RelationalDbHealthContributor>());

            var status = h.Health();

            Assert.Equal(HealthStatus.DOWN, status.Status);
            Assert.Contains(status.Details.Keys, k => k == "error");
        }