require "test/unit"
require "phi"
require "rdb/rdb"
require "rdb/bde"

# BDE
class TCDatabase < Test::Unit::TestCase
  def test_truth
    assert true
  end

  def test_new_with_database
    proc do
      database = Phi::Database.new 'IBLocal', 'SYSDBA', 'masterkey'
      Phi::SESSION.close_database(database)
    end.call
    GC.start
    assert_equal 0, Phi::SESSION.database_count
  end
end

class TCTable < Test::Unit::TestCase
  def test_new
    table = Phi::Table.new
  end
end

class TCQuery < Test::Unit::TestCase
  def test_new
    query = Phi::Query.new
  end

  def test_new_with_database
    proc do
      database = Phi::Database.new 'IBLocal', 'SYSDBA', 'masterkey'
      query = Phi::Query.new database
      Phi::SESSION.close_database(database)
    end.call
    GC.start
    assert_equal 0, Phi::SESSION.database_count
  end
end
