public void DefaultCommandTimeout() { if (Conn.Connector.DefaultCommandTimeout >= 100 && Conn.Connector.DefaultCommandTimeout < 105) { TestUtil.Inconclusive("Bad default command timeout"); } using (var c1 = new NpgsqlConnection(ConnectionString + ";CommandTimeout=100")) { using (var cmd = c1.CreateCommand()) { Assert.That(cmd.CommandTimeout, Is.EqualTo(100)); using (var c2 = new NpgsqlConnection(ConnectionString + ";CommandTimeout=101")) { cmd.Connection = c2; Assert.That(cmd.CommandTimeout, Is.EqualTo(101)); } cmd.CommandTimeout = 102; using (var c2 = new NpgsqlConnection(ConnectionString + ";CommandTimeout=101")) { cmd.Connection = c2; Assert.That(cmd.CommandTimeout, Is.EqualTo(102)); } } } }
public void CheckSslSupport() { var sslSupport = (string)ExecuteScalar("SHOW ssl", Conn); if (sslSupport == "off") { TestUtil.Inconclusive("SSL support isn't enabled at the backend"); } }
public virtual void TestFixtureSetup() { SetupLogging(); var connStringEnvVar = "NPGSQL_TEST_DB_" + BackendVersion; _connectionString = Environment.GetEnvironmentVariable(connStringEnvVar); if (_connectionString == null) { if (BackendVersion == LatestBackendVersion) { _connectionString = DEFAULT_CONNECTION_STRING; Console.WriteLine("Using internal default connection string: " + _connectionString); } else { Assert.Ignore("Skipping tests for backend version {0}, environment variable {1} isn't defined", BackendVersion, connStringEnvVar); return; } } else { Console.WriteLine("Using connection string provided in env var {0}: {1}", connStringEnvVar, _connectionString); } if (!_schemaCreated) { try { Conn = new NpgsqlConnection(ConnectionString); Conn.Open(); CreateSchema(); Console.WriteLine("Schema created successfully. Backend version is " + Conn.PostgreSqlVersion); } catch (NpgsqlException e) { try { if (Conn != null && Conn.State == ConnectionState.Open) { Conn.Close(); } } catch { } if (e.Code == "3D000") { TestUtil.Inconclusive("Please create a database npgsql_tests, owned by user npgsql_tests"); } else if (e.Code == "28P01") { TestUtil.Inconclusive( "Please create a user npgsql_tests as follows: create user npgsql_tests with password 'npgsql_tests'"); } else { throw; } } catch { try { if (Conn != null && Conn.State == ConnectionState.Open) { Conn.Close(); } } catch {} throw; } } }