public async Task Connection_is_opened_and_closed_by_using_transaction_async() { using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension { ConnectionString = "Database=FrodoLives" }))) { Assert.Equal(0, connection.DbConnections.Count); var transaction = await connection.BeginTransactionAsync(); Assert.Equal(1, connection.DbConnections.Count); var dbConnection = connection.DbConnections[0]; Assert.Equal(1, dbConnection.DbTransactions.Count); var dbTransaction = dbConnection.DbTransactions[0]; Assert.Equal(1, dbConnection.OpenCount); Assert.Equal(0, dbConnection.CloseCount); Assert.Equal(IsolationLevel.Unspecified, dbTransaction.IsolationLevel); transaction.Dispose(); Assert.Equal(1, dbConnection.OpenCount); Assert.Equal(1, dbConnection.CloseCount); } }
public async Task Transaction_can_begin_with_isolation_level_async() { using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension { ConnectionString = "Database=FrodoLives" }))) { Assert.Equal(0, connection.DbConnections.Count); using (var transaction = await connection.BeginTransactionAsync(IsolationLevel.Chaos)) { Assert.Equal(1, connection.DbConnections.Count); var dbConnection = connection.DbConnections[0]; Assert.Equal(1, dbConnection.DbTransactions.Count); var dbTransaction = dbConnection.DbTransactions[0]; Assert.Equal(IsolationLevel.Chaos, dbTransaction.IsolationLevel); } } }