public void ConnectionRefused(bool pooled)
{
var csb = new NpgsqlConnectionStringBuilder(ConnectionString) { Port = 44444, Pooling = pooled };
using (var conn = new NpgsqlConnection(csb)) {
Assert.That(() => conn.Open(), Throws.Exception
.TypeOf<SocketException>()
#if !NETCOREAPP1_0
// CoreCLR currently has an issue which causes the wrong SocketErrorCode to be set on Linux:
// https://github.com/dotnet/corefx/issues/8464
.With.Property(nameof(SocketException.SocketErrorCode)).EqualTo(SocketError.ConnectionRefused)
#endif
);
Assert.That(conn.FullState, Is.EqualTo(ConnectionState.Closed));
}
}