/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using (var connection = new FbConnection(connectionString)) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var dataSource = new FbConnectionStringBuilder(connectionString).DataSource; var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = GetVersionFromServerVersionString(connection.ServerVersion), ConnectionString = connectionString, MultipleActiveResultSets = true, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (Int32.Parse(coreServerInfo.ServerVersion.Major.ToString() + coreServerInfo.ServerVersion.Minor.ToString()) < 25) { throw new NotSupportedException(Strings.ExFirebirdBelow25IsNotSupported); } if (coreServerInfo.ServerVersion.Major == 2 && coreServerInfo.ServerVersion.Minor == 5) { return(new v2_5.Driver(coreServerInfo)); } return(null); } }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using (var connection = new OracleConnection(connectionString)) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var version = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? ParseVersion(connection.ServerVersion) : new Version(configuration.ForcedServerVersion); var dataSource = new OracleConnectionStringBuilder(connectionString).DataSource; var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = true, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 9 || version.Major == 9 && version.Minor < 2) { throw new NotSupportedException(Strings.ExOracleBelow9i2IsNotSupported); } if (version.Major == 9) { return(new v09.Driver(coreServerInfo)); } if (version.Major == 10) { return(new v10.Driver(coreServerInfo)); } return(new v11.Driver(coreServerInfo)); } }
/// <inheritdoc/> protected override async Task <SqlDriver> CreateDriverAsync( string connectionString, SqlDriverConfiguration configuration, CancellationToken token) { var isPooingOn = !IsPoolingOff(connectionString); configuration.EnsureConnectionIsAlive &= isPooingOn; var connection = await CreateAndOpenConnectionAsync(connectionString, configuration, token).ConfigureAwait(false); await using (connection.ConfigureAwait(false)) { var isEnsureAlive = configuration.EnsureConnectionIsAlive; var forcedServerVersion = configuration.ForcedServerVersion; var isForcedVersion = !string.IsNullOrEmpty(forcedServerVersion); var isForcedAzure = isForcedVersion && forcedServerVersion.Equals("azure", StringComparison.OrdinalIgnoreCase); var isAzure = isForcedAzure || (!isForcedVersion && await IsAzureAsync(connection, token).ConfigureAwait(false)); var parser = isAzure ? new ErrorMessageParser() : await CreateMessageParserAsync(connection, token).ConfigureAwait(false); var versionString = isForcedVersion ? isForcedAzure ? "10.0.0.0" : forcedServerVersion : connection.ServerVersion ?? string.Empty; var version = new Version(versionString); var defaultSchema = await GetDefaultSchemaAsync(connection, token : token).ConfigureAwait(false); return(CreateDriverInstance(connectionString, isAzure, version, defaultSchema, parser, isEnsureAlive)); } }
private static Version GetVersion(SqlDriverConfiguration configuration, NpgsqlConnection connection) { var version = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? connection.PostgreSqlVersion : new Version(configuration.ForcedServerVersion); return(version); }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using var connection = new SQLiteConnection(connectionString); connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var defaultSchema = GetDefaultSchema(connection); var version = new Version(connection.ServerVersion ?? string.Empty); return(CreateDriverInstance(connectionString, version, defaultSchema)); }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using var connection = new OracleConnection(connectionString); connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var version = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? ParseVersion(connection.ServerVersion) : new Version(configuration.ForcedServerVersion); var defaultSchema = GetDefaultSchema(connection); return(CreateDriverInstance(connectionString, version, defaultSchema)); }
private async ValueTask OpenConnectionWithNotification(NpgsqlConnection connection, SqlDriverConfiguration configuration, bool isAsync, CancellationToken cancellationToken = default) { var accessors = configuration.DbConnectionAccessors; if (!isAsync) { SqlHelper.NotifyConnectionOpening(accessors, connection); try { connection.Open(); if (!string.IsNullOrEmpty(configuration.ConnectionInitializationSql)) { SqlHelper.NotifyConnectionInitializing(accessors, connection, configuration.ConnectionInitializationSql); } SqlHelper.ExecuteInitializationSql(connection, configuration); SqlHelper.NotifyConnectionOpened(accessors, connection); } catch (Exception ex) { SqlHelper.NotifyConnectionOpeningFailed(accessors, connection, ex); throw; } } else { await SqlHelper.NotifyConnectionOpeningAsync(accessors, connection, false, cancellationToken).ConfigureAwait(false); try { await connection.OpenAsync(cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(configuration.ConnectionInitializationSql)) { await SqlHelper.NotifyConnectionInitializingAsync(accessors, connection, configuration.ConnectionInitializationSql, false, cancellationToken) .ConfigureAwait(false); } await SqlHelper.ExecuteInitializationSqlAsync(connection, configuration, cancellationToken).ConfigureAwait(false); await SqlHelper.NotifyConnectionOpenedAsync(accessors, connection, false, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { await SqlHelper.NotifyConnectionOpeningFailedAsync(accessors, connection, ex, false, cancellationToken).ConfigureAwait(false); throw; } } }
private static async ValueTask OpenConnectionFast(FbConnection connection, SqlDriverConfiguration configuration, bool isAsync, CancellationToken cancellationToken = default) { if (!isAsync) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); } else { await connection.OpenAsync().ConfigureAwait(false); await SqlHelper.ExecuteInitializationSqlAsync(connection, configuration, cancellationToken).ConfigureAwait(false); } }
// Constructors public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfiguration configuration) { ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory)); ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); var driverConfiguration = new SqlDriverConfiguration { ForcedServerVersion = configuration.ForcedServerVersion, ConnectionInitializationSql = configuration.ConnectionInitializationSql, EnsureConnectionIsAlive = configuration.EnsureConnectionIsAlive, }; var driver = driverFactory.GetDriver(configuration.ConnectionInfo, driverConfiguration); var providerInfo = ProviderInfoBuilder.Build(configuration.ConnectionInfo.Provider, driver); return(new StorageDriver(driver, providerInfo, configuration, GetNullModel)); }
/// <inheritdoc/> protected override async Task <SqlDriver> CreateDriverAsync( string connectionString, SqlDriverConfiguration configuration, CancellationToken token) { var connection = new SQLiteConnection(connectionString); await using (connection.ConfigureAwait(false)) { await connection.OpenAsync(token).ConfigureAwait(false); await SqlHelper.ExecuteInitializationSqlAsync(connection, configuration, token).ConfigureAwait(false); var defaultSchema = await GetDefaultSchemaAsync(connection, token : token).ConfigureAwait(false); var version = new Version(connection.ServerVersion ?? string.Empty); return(CreateDriverInstance(connectionString, version, defaultSchema)); } }
protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using var connection = new NpgsqlConnection(connectionString); if (configuration.DbConnectionAccessors.Count > 0) { OpenConnectionWithNotification(connection, configuration, false).GetAwaiter().GetResult(); } else { OpenConnectionFast(connection, configuration, false).GetAwaiter().GetResult(); } var version = GetVersion(configuration, connection); var defaultSchema = GetDefaultSchema(connection); return(CreateDriverInstance(connectionString, version, defaultSchema)); }
protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using (var connection = new NpgsqlConnection(connectionString)) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var version = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? connection.PostgreSqlVersion : new Version(configuration.ForcedServerVersion); var builder = new NpgsqlConnectionStringBuilder(connectionString); var dataSource = string.Format(DataSourceFormat, builder.Host, builder.Port, builder.Database); var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 8 || version.Major == 8 && version.Minor < 3) { throw new NotSupportedException(Strings.ExPostgreSqlBelow83IsNotSupported); } // We support 8.3, 8.4 and any 9.0+ if (version.Major == 8) { if (version.Minor == 3) { return(new v8_3.Driver(coreServerInfo)); } return(new v8_4.Driver(coreServerInfo)); } if (version.Major == 9) { if (version.Minor == 0) { return(new v9_0.Driver(coreServerInfo)); } return(new v9_1.Driver(coreServerInfo)); } return(new v10_0.Driver(coreServerInfo)); } }
public void ConntectionTest() { var descriptor = ProviderDescriptor.Get(provider); var factory = (SqlDriverFactory)Activator.CreateInstance(descriptor.DriverFactory); var configuration = new SqlDriverConfiguration { EnsureConnectionIsAlive = true }; var driver = factory.GetDriver(new ConnectionInfo(Url), configuration); var connection = driver.CreateConnection(); connection.Open(); var anotherConnection = driver.CreateConnection(); anotherConnection.OpenAndInitialize("Use [DO-Tests-1]"); }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using var connection = new OracleConnection(connectionString); if (configuration.DbConnectionAccessors.Count > 0) { OpenConnectionWithNotification(connection, configuration, false).GetAwaiter().GetResult(); } else { OpenConnectionFast(connection, configuration, false).GetAwaiter().GetResult(); } var version = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? ParseVersion(connection.ServerVersion) : new Version(configuration.ForcedServerVersion); var defaultSchema = GetDefaultSchema(connection); return(CreateDriverInstance(connectionString, version, defaultSchema)); }
protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { using (var connection = new MySqlConnection(connectionString)) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var versionString = string.IsNullOrEmpty(configuration.ForcedServerVersion) ? connection.ServerVersion : configuration.ForcedServerVersion; var version = ParseVersion(versionString); var builder = new MySqlConnectionStringBuilder(connectionString); var dataSource = string.Format(DataSourceFormat, builder.Server, builder.Port, builder.Database); var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 5) { throw new NotSupportedException(Strings.ExMySqlBelow50IsNotSupported); } if (version.Major == 5 && version.Minor == 0) { return(new v5_0.Driver(coreServerInfo)); } if (version.Major == 5 && version.Minor == 1) { return(new v5_1.Driver(coreServerInfo)); } if (version.Major == 5 && version.Minor == 5) { return(new v5_5.Driver(coreServerInfo)); } if (version.Major == 5 && version.Minor == 6) { return(new v5_6.Driver(coreServerInfo)); } return(new v5_6.Driver(coreServerInfo)); } }
private void OpenConnectionWithNotification(SQLiteConnection connection, SqlDriverConfiguration configuration) { var accessors = configuration.DbConnectionAccessors; SqlHelper.NotifyConnectionOpening(accessors, connection); try { connection.Open(); if (!string.IsNullOrEmpty(configuration.ConnectionInitializationSql)) { SqlHelper.NotifyConnectionInitializing(accessors, connection, configuration.ConnectionInitializationSql); } SqlHelper.ExecuteInitializationSql(connection, configuration); SqlHelper.NotifyConnectionOpened(accessors, connection); } catch (Exception ex) { SqlHelper.NotifyConnectionOpeningFailed(accessors, connection, ex); throw; } }
private SqlServerConnection CreateAndOpenConnection(string connectionString, SqlDriverConfiguration configuration) { var connection = new SqlServerConnection(connectionString); if (!configuration.EnsureConnectionIsAlive) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); return(connection); } var testQuery = (string.IsNullOrEmpty(configuration.ConnectionInitializationSql)) ? CheckConnectionQuery : configuration.ConnectionInitializationSql; connection.Open(); EnsureConnectionIsAlive(ref connection, testQuery); return(connection); }
public static async Task <StorageDriver> CreateAsync( SqlDriverFactory driverFactory, DomainConfiguration configuration, CancellationToken token) { ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory)); ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration)); var driverConfiguration = new SqlDriverConfiguration { ForcedServerVersion = configuration.ForcedServerVersion, ConnectionInitializationSql = configuration.ConnectionInitializationSql, EnsureConnectionIsAlive = configuration.EnsureConnectionIsAlive, }; var driver = await driverFactory.GetDriverAsync(configuration.ConnectionInfo, driverConfiguration, token) .ConfigureAwait(false); var providerInfo = ProviderInfoBuilder.Build(configuration.ConnectionInfo.Provider, driver); return(new StorageDriver(driver, providerInfo, configuration, GetNullModel)); }
/// <inheritdoc/> protected override async Task <SqlDriver> CreateDriverAsync( string connectionString, SqlDriverConfiguration configuration, CancellationToken token) { var connection = new NpgsqlConnection(connectionString); await using (connection.ConfigureAwait(false)) { if (configuration.DbConnectionAccessors.Count > 0) { await OpenConnectionWithNotification(connection, configuration, true, token).ConfigureAwait(false); } else { await OpenConnectionFast(connection, configuration, true, token).ConfigureAwait(false); } var version = GetVersion(configuration, connection); var defaultSchema = await GetDefaultSchemaAsync(connection, token : token).ConfigureAwait(false); return(CreateDriverInstance(connectionString, version, defaultSchema)); } }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { var isPooingOn = !IsPoolingOff(connectionString); configuration.EnsureConnectionIsAlive &= isPooingOn; using var connection = CreateAndOpenConnection(connectionString, configuration); var isEnsureAlive = configuration.EnsureConnectionIsAlive; var forcedServerVersion = configuration.ForcedServerVersion; var isForcedVersion = !string.IsNullOrEmpty(forcedServerVersion); var isForcedAzure = isForcedVersion && forcedServerVersion.Equals("azure", StringComparison.OrdinalIgnoreCase); var isAzure = isForcedAzure || (!isForcedVersion && IsAzure(connection)); var parser = isAzure ? new ErrorMessageParser() : CreateMessageParser(connection); var versionString = isForcedVersion ? isForcedAzure ? "10.0.0.0" : forcedServerVersion : connection.ServerVersion ?? string.Empty; var version = new Version(versionString); var defaultSchema = GetDefaultSchema(connection); return(CreateDriverInstance(connectionString, isAzure, version, defaultSchema, parser, isEnsureAlive)); }
private SqlDriver DoCreateDriver(string connectionString, SqlDriverConfiguration configuration) { using (var connection = new SQLiteConnection(connectionString)) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); var version = new Version(connection.ServerVersion); var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = false, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (version.Major < 3) { throw new NotSupportedException(Strings.ExSqlLiteServerBelow3IsNotSupported); } return(new v3.Driver(coreServerInfo)); } }
public void SqlServerConnectionCheckTest() { Require.ProviderIs(StorageProvider.SqlServer); var descriptor = ProviderDescriptor.Get(provider); var factory = (SqlDriverFactory)Activator.CreateInstance(descriptor.DriverFactory); var configuration = new SqlDriverConfiguration() { EnsureConnectionIsAlive = false }; var driver = factory.GetDriver(new ConnectionInfo(Url), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.False); configuration = configuration.Clone(); configuration.EnsureConnectionIsAlive = true; driver = factory.GetDriver(new ConnectionInfo(Url), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.True); configuration = configuration.Clone(); configuration.EnsureConnectionIsAlive = true; driver = factory.GetDriver(new ConnectionInfo(provider, ConnectionString + ";pooling=false"), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.False); configuration = configuration.Clone(); configuration.EnsureConnectionIsAlive = true; driver = factory.GetDriver(new ConnectionInfo(provider, ConnectionString + ";Pooling=False"), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.False); configuration = configuration.Clone(); configuration.EnsureConnectionIsAlive = true; driver = factory.GetDriver(new ConnectionInfo(provider, ConnectionString + ";pooling = false"), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.False); configuration = configuration.Clone(); configuration.EnsureConnectionIsAlive = true; driver = factory.GetDriver(new ConnectionInfo(provider, ConnectionString + ";Pooling = False"), configuration); Assert.That(GetCheckConnectionIsAliveFlag(driver), Is.False); }
private void OpenConnectionFast(SQLiteConnection connection, SqlDriverConfiguration configuration) { connection.Open(); SqlHelper.ExecuteInitializationSql(connection, configuration); }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { var isPooingOn = !IsPoolingOff(connectionString); configuration.EnsureConnectionIsAlive = isPooingOn && configuration.EnsureConnectionIsAlive; using (var connection = CreateAndOpenConnection(connectionString, configuration)) { string versionString; bool isAzure; var forcedServerVersion = configuration.ForcedServerVersion; if (string.IsNullOrEmpty(forcedServerVersion)) { versionString = connection.ServerVersion; isAzure = IsAzure(connection); } else if (forcedServerVersion.Equals("azure", StringComparison.OrdinalIgnoreCase)) { versionString = "10.0.0.0"; isAzure = true; } else { versionString = forcedServerVersion; isAzure = false; } var builder = new SqlConnectionStringBuilder(connectionString); var version = new Version(versionString); var defaultSchema = GetDefaultSchema(connection); var coreServerInfo = new CoreServerInfo { ServerVersion = version, ConnectionString = connectionString, MultipleActiveResultSets = builder.MultipleActiveResultSets, DatabaseName = defaultSchema.Database, DefaultSchemaName = defaultSchema.Schema, }; if (isAzure) { return(new Azure.Driver(coreServerInfo, new ErrorMessageParser(), configuration.EnsureConnectionIsAlive)); } if (version.Major < 9) { throw new NotSupportedException(Strings.ExSqlServerBelow2005IsNotSupported); } var parser = CreateMessageParser(connection); if (version.Major == 9) { return(new v09.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } if (version.Major == 10) { return(new v10.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } if (version.Major == 11) { return(new v11.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } if (version.Major == 12) { return(new v12.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } if (version.Major == 13) { return(new v13.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } return(new v13.Driver(coreServerInfo, parser, configuration.EnsureConnectionIsAlive)); } }
/// <inheritdoc/> protected override SqlDriver CreateDriver(string connectionString, SqlDriverConfiguration configuration) { return(DoCreateDriver(connectionString, configuration)); }
public async Task ConnectionAccessorAsyncTest() { var accessorInstance = new TestConnectionAccessor(); var accessorsArray = new[] { accessorInstance }; var descriptor = ProviderDescriptor.Get(provider); var factory = (SqlDriverFactory)Activator.CreateInstance(descriptor.DriverFactory); Assert.That(accessorInstance.OpeningCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningAsyncCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpenedCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpenedAsyncCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningFailedCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningFailedAsyncCounter, Is.EqualTo(0)); var configuration = new SqlDriverConfiguration(accessorsArray); _ = await factory.GetDriverAsync(new ConnectionInfo(Url), configuration, CancellationToken.None); Assert.That(accessorInstance.OpeningCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningAsyncCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpenedCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpenedAsyncCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningFailedCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningFailedAsyncCounter, Is.EqualTo(0)); configuration = new SqlDriverConfiguration(accessorsArray) { EnsureConnectionIsAlive = true }; _ = await factory.GetDriverAsync(new ConnectionInfo(Url), configuration, CancellationToken.None); Assert.That(accessorInstance.OpeningCounter, Is.EqualTo(2)); Assert.That(accessorInstance.OpeningAsyncCounter, Is.EqualTo(2)); if (provider == WellKnown.Provider.SqlServer) { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(1)); } else { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(0)); } Assert.That(accessorInstance.OpenedCounter, Is.EqualTo(2)); Assert.That(accessorInstance.OpenedAsyncCounter, Is.EqualTo(2)); Assert.That(accessorInstance.OpeningFailedCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningFailedAsyncCounter, Is.EqualTo(0)); configuration = new SqlDriverConfiguration(accessorsArray) { ConnectionInitializationSql = InitQueryPerProvider(provider) }; _ = await factory.GetDriverAsync(new ConnectionInfo(Url), configuration, CancellationToken.None); Assert.That(accessorInstance.OpeningCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpeningAsyncCounter, Is.EqualTo(3)); if (provider == WellKnown.Provider.SqlServer) { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(2)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(2)); } else { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(1)); } Assert.That(accessorInstance.OpenedCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpenedAsyncCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpeningFailedCounter, Is.EqualTo(0)); Assert.That(accessorInstance.OpeningFailedAsyncCounter, Is.EqualTo(0)); configuration = new SqlDriverConfiguration(accessorsArray) { ConnectionInitializationSql = "dummy string to trigger error" }; try { _ = await factory.GetDriverAsync(new ConnectionInfo(Url), configuration, CancellationToken.None); } catch { //skip it } Assert.That(accessorInstance.OpeningCounter, Is.EqualTo(4)); Assert.That(accessorInstance.OpeningAsyncCounter, Is.EqualTo(4)); if (provider == WellKnown.Provider.SqlServer) { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(3)); } else { Assert.That(accessorInstance.OpeningInitCounter, Is.EqualTo(2)); Assert.That(accessorInstance.OpeningInitAsyncCounter, Is.EqualTo(2)); } Assert.That(accessorInstance.OpenedCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpenedAsyncCounter, Is.EqualTo(3)); Assert.That(accessorInstance.OpeningFailedCounter, Is.EqualTo(1)); Assert.That(accessorInstance.OpeningFailedAsyncCounter, Is.EqualTo(1)); }