#!/usr/bin/perl -w

use Test::More 'no_plan';
require WWW::Yahoo::Credentials;

my $credentials = WWW::Yahoo::Credentials->new( 't/files/credentials3.xml' );
ok( defined $credentials, 'new WWW::Yahoo::Credentials' );

my $userid1 = 'userid1';
my $password1 = $credentials->password( $userid1 );
my $key1 = $credentials->security_key( $userid1 );
is( $password1, 'password1', 'password 1' );
ok( ! defined $key1, 'key 1' );

my $userid2 = 'userid2';
my $password2 = $credentials->password( $userid2 );
my $key2 = $credentials->security_key( $userid2 );
is( $password2, 'password2', 'password 2' );
is( $key2, '', 'key 2' );

my $userid3 = 'userid3';
my $password3 = $credentials->password( $userid3 );
my $key3 = $credentials->security_key( $userid3 );
is( $password3, 'password3', 'password 3' );
is( $key3, 'key3', 'key 3' );

my( $userid, $password, $key ) = $credentials->tuple;
is( $userid1, 'userid1', 'userid 1' );
is( $password1, 'password1', 'password 1' );
ok( ! defined $key1, 'key 1' );

my @userids = $credentials->userids;
is( scalar @userids, 3, 'userids' );
is( $userids[0], 'userid1', 'userid 1' );
is( $userids[1], 'userid2', 'userid 2' );
is( $userids[2], 'userid3', 'userid 3' );

( $userid1, $password1, $key1 ) = $credentials->tuple( $userid1 );
is( $userid1, 'userid1', 'userid 1' );
is( $password1, 'password1', 'password 1' );
ok( ! defined $key1, 'key 1' );

( $userid2, $password2, $key2 ) = $credentials->tuple( $userid2 );
is( $userid2, 'userid2', 'userid 2' );
is( $password2, 'password2', 'password 2' );
is( $key2, '', 'key 2' );

( $userid3, $password3, $key3 ) = $credentials->tuple( $userid3 );
is( $userid3, 'userid3', 'userid 3' );
is( $password3, 'password3', 'password 3' );
is( $key3, 'key3', 'key 3' );

my( $userid4, $password4, $key4 ) = $credentials->tuple( 'userid4' );
ok( ! defined $userid4, 'userid 4' );
ok( ! defined $password4, 'password 4' );
ok( ! defined $key4, 'key 4' );
