Skip to content

Commit

Permalink
Fix whitespace and indentation formatting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrainger committed Jan 14, 2024
1 parent 43a25e0 commit babef3b
Show file tree
Hide file tree
Showing 21 changed files with 218 additions and 215 deletions.
2 changes: 1 addition & 1 deletion src/MySqlConnector/Core/MetricsReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static IEnumerable<Measurement<int>> GetMinimumConnections() =>
private static readonly UpDownCounter<int> s_pendingRequestsCounter = ActivitySourceHelper.Meter.CreateUpDownCounter<int>("db.client.connections.pending_requests",
unit: "{request}", description: "The number of pending requests for an open connection, cumulative for the entire pool.");
private static readonly Counter<int> s_connectionTimeouts = ActivitySourceHelper.Meter.CreateCounter<int>("db.client.connections.timeouts",
unit: "{timeout}", description: "The number of connection timeouts that have occurred trying to obtain a connection from the pool.");
unit: "{timeout}", description: "The number of connection timeouts that have occurred trying to obtain a connection from the pool.");
private static readonly Histogram<double> s_createTimeHistory = ActivitySourceHelper.Meter.CreateHistogram<double>("db.client.connections.create_time",
unit: "s", description: "The time it took to create a new connection.");
private static readonly Histogram<double> s_useTimeHistory = ActivitySourceHelper.Meter.CreateHistogram<double>("db.client.connections.use_time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public int Offset
if (value < 0 || value > m_maxOffset)
throw new ArgumentOutOfRangeException(nameof(value), $"value must be between 0 and {m_maxOffset:d}");
#endif
m_offset = value;
m_offset = value;
}
}

Expand Down
14 changes: 7 additions & 7 deletions tests/Conformance.Tests/DbFactoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
namespace Conformance.Tests;

public class DbFactoryFixture : IDbFactoryFixture
{
public DbFactoryFixture()
{
public DbFactoryFixture()
{
ConnectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING") ?? "Server=localhost;User Id=mysqltest;Password=test;SSL Mode=None;AllowPublicKeyRetrieval=true";
}

public string ConnectionString { get; }
public DbProviderFactory Factory => MySqlConnectorFactory.Instance;
ConnectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING") ?? "Server=localhost;User Id=mysqltest;Password=test;SSL Mode=None;AllowPublicKeyRetrieval=true";
}

public string ConnectionString { get; }
public DbProviderFactory Factory => MySqlConnectorFactory.Instance;
}
42 changes: 21 additions & 21 deletions tests/IntegrationTests/BulkLoaderSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,34 +1243,34 @@ public void BulkCopyDataTableConflictOption(MySqlBulkLoaderConflictOption confli

switch (conflictOption)
{
case MySqlBulkLoaderConflictOption.None:
var exception = Assert.Throws<MySqlException>(() => bulkCopy.WriteToServer(dataTable));
Assert.Equal(MySqlErrorCode.BulkCopyFailed, exception.ErrorCode);
break;

case MySqlBulkLoaderConflictOption.Replace:
var replaceResult = bulkCopy.WriteToServer(dataTable);
Assert.Equal(expectedRowsInserted, replaceResult.RowsInserted);
Assert.Empty(replaceResult.Warnings);
break;

case MySqlBulkLoaderConflictOption.Ignore:
var ignoreResult = bulkCopy.WriteToServer(dataTable);
Assert.Equal(expectedRowsInserted, ignoreResult.RowsInserted);
if (!connection.ServerVersion.StartsWith("5.6.", StringComparison.Ordinal))
{
var error = Assert.Single(ignoreResult.Warnings);
Assert.Equal(MySqlErrorCode.DuplicateKeyEntry, error.ErrorCode);
}
break;
case MySqlBulkLoaderConflictOption.None:
var exception = Assert.Throws<MySqlException>(() => bulkCopy.WriteToServer(dataTable));
Assert.Equal(MySqlErrorCode.BulkCopyFailed, exception.ErrorCode);
break;

case MySqlBulkLoaderConflictOption.Replace:
var replaceResult = bulkCopy.WriteToServer(dataTable);
Assert.Equal(expectedRowsInserted, replaceResult.RowsInserted);
Assert.Empty(replaceResult.Warnings);
break;

case MySqlBulkLoaderConflictOption.Ignore:
var ignoreResult = bulkCopy.WriteToServer(dataTable);
Assert.Equal(expectedRowsInserted, ignoreResult.RowsInserted);
if (!connection.ServerVersion.StartsWith("5.6.", StringComparison.Ordinal))
{
var error = Assert.Single(ignoreResult.Warnings);
Assert.Equal(MySqlErrorCode.DuplicateKeyEntry, error.ErrorCode);
}
break;
}

using (var cmd = new MySqlCommand("select b from bulk_load_data_table;", connection))
Assert.Equal(expected, cmd.ExecuteScalar());
}
#endif

internal static string GetConnectionString() => AppConfig.ConnectionString;
internal static string GetConnectionString() => AppConfig.ConnectionString;

internal static string GetLocalConnectionString()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTests/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void ExecuteNonQueryForSelectReturnsNegativeOne()
Assert.Equal(-1, command.ExecuteNonQuery());
}

[Fact]
[Fact]
public async Task ExecuteNonQueryReturnValue()
{
using var connection = new MySqlConnection(m_database.Connection.ConnectionString);
Expand Down
26 changes: 13 additions & 13 deletions tests/IntegrationTests/DataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,19 @@ private async Task DoGetValue<T>(string column, Func<MySqlDataReader, int, T> ge
Assert.True(await reader.ReadAsync().ConfigureAwait(false));
switch (flags[i])
{
case 0: // normal
Assert.Equal(values[i], getInt(reader, 0));
Assert.Equal(values[i], getIntByName(reader, column));
break;

case 1: // null
Assert.True(await reader.IsDBNullAsync(0).ConfigureAwait(false));
break;

case 2: // overflow
Assert.Throws<OverflowException>(() => getInt(reader, 0));
Assert.Throws<OverflowException>(() => getIntByName(reader, column));
break;
case 0: // normal
Assert.Equal(values[i], getInt(reader, 0));
Assert.Equal(values[i], getIntByName(reader, column));
break;

case 1: // null
Assert.True(await reader.IsDBNullAsync(0).ConfigureAwait(false));
break;

case 2: // overflow
Assert.Throws<OverflowException>(() => getInt(reader, 0));
Assert.Throws<OverflowException>(() => getIntByName(reader, column));
break;
}
}
Assert.False(await reader.ReadAsync().ConfigureAwait(false));
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTests/InsertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ value mediumblob null
cmd.Prepare();
cmd.ExecuteNonQuery();
}
Assert.Equal(new byte[] { 1, 0, 2, 39, 3, 92, 4, 34, 5, 6 }, connection.Query<byte[]>(@"select value from insert_mysql_blob;").Single());
Assert.Equal(new byte[] { 1, 0, 2, 39, 3, 92, 4, 34, 5, 6 }, connection.Query<byte[]>(@"select value from insert_mysql_blob;").Single());
}

public static IEnumerable<object[]> GetBlobs()
Expand Down
3 changes: 2 additions & 1 deletion tests/IntegrationTests/LoadDataInfileAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public async Task CommandLoadCsvFile()
{
var insertInlineCommand = string.Format(m_loadDataInfileCommand, "", AppConfig.MySqlBulkLoaderCsvFile.Replace("\\", "\\\\"));
using var command = new MySqlCommand(insertInlineCommand, m_database.Connection);
if (m_database.Connection.State != ConnectionState.Open) await m_database.Connection.OpenAsync();
if (m_database.Connection.State != ConnectionState.Open)
await m_database.Connection.OpenAsync();
var rowCount = await command.ExecuteNonQueryAsync();
m_database.Connection.Close();
Assert.Equal(20, rowCount);
Expand Down
6 changes: 4 additions & 2 deletions tests/IntegrationTests/LoadDataInfileSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void CommandLoadCsvFile()
{
var insertInlineCommand = string.Format(m_loadDataInfileCommand, "", AppConfig.MySqlBulkLoaderCsvFile.Replace("\\", "\\\\"));
using var command = new MySqlCommand(insertInlineCommand, m_database.Connection);
if (m_database.Connection.State != ConnectionState.Open) m_database.Connection.Open();
if (m_database.Connection.State != ConnectionState.Open)
m_database.Connection.Open();
var rowCount = command.ExecuteNonQuery();
m_database.Connection.Close();
Assert.Equal(20, rowCount);
Expand All @@ -41,7 +42,8 @@ public void CommandLoadLocalCsvFile()
{
var insertInlineCommand = string.Format(m_loadDataInfileCommand, " LOCAL", AppConfig.MySqlBulkLoaderLocalCsvFile.Replace("\\", "\\\\"));
using var command = new MySqlCommand(insertInlineCommand, m_database.Connection);
if (m_database.Connection.State != ConnectionState.Open) m_database.Connection.Open();
if (m_database.Connection.State != ConnectionState.Open)
m_database.Connection.Open();
var rowCount = command.ExecuteNonQuery();
m_database.Connection.Close();
Assert.Equal(20, rowCount);
Expand Down
18 changes: 9 additions & 9 deletions tests/IntegrationTests/MySqlDataSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public void OpenConnection()
Assert.Equal(ConnectionState.Open, connection.State);
}

[Fact]
public void DoubleDispose()
{
using var dbSource = new MySqlDataSource(AppConfig.ConnectionString);
[Fact]
public void DoubleDispose()
{
using var dbSource = new MySqlDataSource(AppConfig.ConnectionString);
using (var connection = dbSource.OpenConnection())
{
Assert.Equal(ConnectionState.Open, connection.State);
}
Assert.Equal(ConnectionState.Open, connection.State);
}
dbSource.Dispose();
}
}

[Fact]
public async Task OpenConnectionAsync()
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public void PasswordProviderFailureIsRetried()
var exception = Assert.Throws<MySqlException>(dataSource.OpenConnection); // Failed to obtain password via ProvidePasswordCallback
Assert.IsType<MySqlException>(exception.InnerException); // The periodic password provider failed
Assert.IsType<ApplicationException>(exception.InnerException.InnerException); // First-time failure

// succeeds after failure retry
barrier.SignalAndWait();
Thread.Sleep(10);
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTests/PreparedCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private enum TwoByteEnum : short
{
Value = 111,
}


private static MySqlConnection CreateConnection()
{
Expand Down
18 changes: 9 additions & 9 deletions tests/IntegrationTests/SchemaProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ public void GetCollationsSchema()

[Fact]
public void ForeignKeys()
{
var schemaName = m_database.Connection.Database;
var table = m_database.Connection.GetSchema("Foreign Keys", new[] { null, schemaName, "fk_test" });
var row = table.Rows.Cast<DataRow>().Single();
foreach (var (column, value) in new[]
{
{
var schemaName = m_database.Connection.Database;
var table = m_database.Connection.GetSchema("Foreign Keys", new[] { null, schemaName, "fk_test" });
var row = table.Rows.Cast<DataRow>().Single();
foreach (var (column, value) in new[]
{
("CONSTRAINT_CATALOG", "def"),
("CONSTRAINT_SCHEMA", schemaName),
("CONSTRAINT_NAME", "fk_test_fk"),
Expand All @@ -200,10 +200,10 @@ public void ForeignKeys()
("REFERENCED_TABLE_SCHEMA", schemaName),
("REFERENCED_TABLE_NAME", "pk_test"),
})
{
{
Assert.Equal(value, row[column] is DBNull ? null : (string?) row[column]);
}
}
}
}

[Fact]
public void Indexes()
Expand Down
22 changes: 11 additions & 11 deletions tests/IntegrationTests/StoredProcedureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,18 +443,18 @@ private async Task<object> ExecuteCommandAsync(DbCommand cmd, string executorTyp
{
switch (executorType)
{
case "NonQuery":
await cmd.ExecuteNonQueryAsync();
return null;
case "Scalar":
return await cmd.ExecuteScalarAsync();
default:
using (var reader = await cmd.ExecuteReaderAsync())
{
if (await reader.ReadAsync())
return reader.GetValue(0);
case "NonQuery":
await cmd.ExecuteNonQueryAsync();
return null;
}
case "Scalar":
return await cmd.ExecuteScalarAsync();
default:
using (var reader = await cmd.ExecuteReaderAsync())
{
if (await reader.ReadAsync())
return reader.GetValue(0);
return null;
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions tests/IntegrationTests/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public static void AssertIsOne(object value)
{
switch (value)
{
case int intValue:
Assert.Equal(1, intValue);
break;
case int intValue:
Assert.Equal(1, intValue);
break;

case long longValue:
Assert.Equal(1L, longValue);
break;
case long longValue:
Assert.Equal(1L, longValue);
break;

default:
Assert.Equal(1L, value);
break;
default:
Assert.Equal(1L, value);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTests/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void TransactionHoldsLocks()
""";
command.ExecuteNonQuery();
}

using var barrier = new Barrier(2);
using var barrier2 = new Barrier(2);

Expand Down
2 changes: 1 addition & 1 deletion tests/MySqlConnector.Tests/CancellationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public async Task ExecuteAsync(int step, int method)

public static IEnumerable<object[]> GetSyncMethodSteps()
{
for (var step = 1; step <= 12; step++)
for (var step = 1; step <= 12; step++)
{
for (var method = 0; method < s_executeMethods.Length; method++)
{
Expand Down
Loading

0 comments on commit babef3b

Please sign in to comment.