Created
October 5, 2009 02:08
-
-
Save spazm/201761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::More; | |
#use Secret::Object; | |
#use Secret::Message; | |
BEGIN { use_ok('Secret::Object') }; | |
BEGIN { use_ok('Secret::Message') }; | |
my %attrs_for_object1 = (); | |
my %attrs_for_object2 = (); | |
my $obj1 = Secret::Object->new(%attrs_for_object1); | |
my $obj2 = Secret::Object->new(%attrs_for_object2); | |
isnt( $obj1->id, $obj2->id, "id is distinct" ); | |
my $message = $obj1->make_message('copy_my_state'); | |
isa_ok( $message, 'Secret::Message' ); | |
my $prior_id = $obj2->id; | |
my $prior_state = $obj2->get_public_state; | |
my $expected_state = $obj1->get_public_state; | |
$obj2->apply_message($message); | |
is( $obj2->id, $prior_id, "id did not change" ); | |
is_deeply( $obj2->state, $expected_state, | |
"state of obj2 set to match state of obj1" ); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment