### ----------------------------------------------------
### -- Win32::Registry
### -- Licenses: Artistic-2.0
### -- Authors: Steve Dondley
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;
use Win32::Registry::Subkeys;
use Win32::Registry;

plan 10;

unless $*DISTRO.is-win {
    skip-rest 'Skipping test. This module will not pass tests on ' ~
        'a non-Windows machine.';
    exit;
}

use-ok 'Win32::Registry';
use-ok 'Win32::Registry::Subkeys';

my $key = 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths';
my $hive = 'hkey_crrent_user';
dies-ok { get-subkeys $hive, $key }, 'dies with bad hive key';

$hive = 'hkey_local_machine';
lives-ok { get-subkeys $hive, $key }, 'lives with good hive key';

$hive = 'LOCAL_MACHINE';
my @sk;
lives-ok { @sk = get-subkeys $hive, $key; },
        'lives with partial, capitalized key';

is @sk.so , True, 'returns populated array';

my $test-key = @sk.shift;

$key = open-key($test-key);
is close-key($key), True, 'closes a known open key';
is close-key($key), False, 'close returns false on unopen key';

is key-exists($test-key), True, 'detects if key exists';

my $bad-key = 'SOFTWARE\Microsoft\Winows\CurrentVersion\App Paths';
dies-ok { get-subkeys $hive, $bad-key }, 'dies with bad key';

done-testing;



