use strict;
use warnings;
use Test::More 'no_plan';
use Test::Exception;
BEGIN { use_ok('WebCoso::Resource'); }
my $r=WebCoso::Resource->new();
isa_ok($r,'WebCoso::Resource');
$r->set_property(prop1=>'value1');
is($r->get_property('prop1'),'value1','simple global');
is($r->get_property({},'prop1'),'value1','explicit global');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value1','over global');
$r->set_property(prop1=>'value2');
is($r->get_property('prop1'),'value2','simple global redef');
is($r->get_property({},'prop1'),'value2','explicit global redef');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value2','over global redef');
$r->set_property({},prop1=>'value3');
is($r->get_property('prop1'),'value3','simple global redef');
is($r->get_property({},'prop1'),'value3','explicit global redef');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value3','over global redef');
$r->set_property({a1=>3},prop2=>'v1');
ok(! defined $r->get_property('prop2'),'undef on generalization');
is($r->get_property({a1=>3},'prop2'),'v1','specific');
is($r->get_property({a1=>3,a2=>3},'prop2'),'v1','over specific');
$r->set_property({a1=>2},prop2=>'v2');
ok(! defined $r->get_property('prop2'),'undef on generalization');
is($r->get_property({a1=>3},'prop2'),'v1','specific, oldval');
is($r->get_property({a1=>3,a2=>3},'prop2'),'v1','over specific, oldval');
is($r->get_property({a1=>2},'prop2'),'v2','specific, newval');
is($r->get_property({a1=>2,a2=>3},'prop2'),'v2','over specific, newval');
$r->set_property({a1=>1,a2=>2},prop3=>'vx');
ok(! defined $r->get_property({a1=>1},'prop3'),'undef on generalization, 2');