public void Commit_calls_commit_on_DbTransaction() { using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension().WithConnectionString("Database=FrodoLives")))) { Assert.Equal(0, connection.DbConnections.Count); Assert.Null(connection.CurrentTransaction); using (var transaction = connection.BeginTransaction()) { Assert.Same(transaction, connection.CurrentTransaction); Assert.Equal(1, connection.DbConnections.Count); var dbConnection = connection.DbConnections[0]; Assert.Equal(1, dbConnection.DbTransactions.Count); var dbTransaction = dbConnection.DbTransactions[0]; connection.CommitTransaction(); Assert.Equal(1, dbTransaction.CommitCount); } Assert.Null(connection.CurrentTransaction); } }
public void Throws_when_commit_is_called_without_active_transaction() { using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension().WithConnectionString("Database=FrodoLives")))) { Assert.Equal(0, connection.DbConnections.Count); Assert.Equal( RelationalStrings.NoActiveTransaction, Assert.Throws <InvalidOperationException>( () => connection.CommitTransaction()).Message); } }