Exemple #1
0
        public void Throws_when_rollback_is_called_without_active_transaction()
        {
            using (var connection = new FakeRelationalConnection(
                       CreateOptions(new FakeRelationalOptionsExtension {
                ConnectionString = "Database=FrodoLives"
            })))
            {
                Assert.Equal(0, connection.DbConnections.Count);

                Assert.Equal(
                    RelationalStrings.NoActiveTransaction,
                    Assert.Throws <InvalidOperationException>(
                        () => connection.RollbackTransaction()).Message);
            }
        }
Exemple #2
0
        public void Rollback_calls_rollback_on_DbTransaction()
        {
            using (var connection = new FakeRelationalConnection(
                       CreateOptions(new FakeRelationalOptionsExtension {
                ConnectionString = "Database=FrodoLives"
            })))
            {
                Assert.Equal(0, connection.DbConnections.Count);

                using (var transaction = connection.BeginTransaction())
                {
                    Assert.Equal(1, connection.DbConnections.Count);
                    var dbConnection = connection.DbConnections[0];

                    Assert.Equal(1, dbConnection.DbTransactions.Count);
                    var dbTransaction = dbConnection.DbTransactions[0];

                    connection.RollbackTransaction();

                    Assert.Equal(1, dbTransaction.RollbackCount);
                }
            }
        }