require "registry"
require 'test/unit/testcase'


class Tester < Test::Unit::TestCase
  def setup
    Registry::open
  end

  def teardown
    Registry::close
  end

  def test_get_keys
    keys = Registry::keys
    assert_true( keys.include?("system"))
    assert_true( keys.include?("user"))
  end

  def test_set_value_candy
    # Testing set value
    name = "user/lib/registry/version"
    value = "0.2.2"
    Registry::set( name,  value )
    assert_equal( value, Registry.get( name ) )
  end

  def test_variable_get
    k = Registry::Variable.new
    k.name = "user/lib/registry/version"
    Registry::get_key( k )
    assert_equal( "0.2.2", k.value )
  end

  def test_get_key_value
    key = Registry::get_key( "user/lib/registry/version" )
    assert_equal( "0.2.2", key.value )
  end

  def test_remove
    Registry::set( "user/lib/registry/version",  "0.2.2" )
    Registry::remove( "user/lib/registry/version" )
    assert_equal( nil, Registry::get('user/lib/registry'))
  end
end
