Permalink
Browse files

test fixes for app layer

  • Loading branch information...
1 parent 89f4c25 commit 9ec71cea56e1d7730acce09f52ed1fbc9ed03de6 @tsee committed Mar 26, 2012
Showing with 15 additions and 4 deletions.
  1. +15 −4 t/20build.t
View
@@ -6,29 +6,40 @@ use Test::More;
my $datadir = -d 't' ? File::Spec->catdir(qw(t data)) : "data";
+# test the ZDCF v0.1 spec file first
my $testzdcf = File::Spec->catfile($datadir, 'simple_v0.zdcf');
ok(-f $testzdcf)
or die "Missing test file";
my $zdcf = ZMQ::Declare::ZDCF->new(tree => $testzdcf);
isa_ok($zdcf, "ZMQ::Declare::ZDCF");
-my @devices = $zdcf->device_names;
+# just the compat "" application
+my @applications = $zdcf->application_names;
+is(scalar(@applications), 1, 'Number of available applications');
+is($applications[0], "", "Contains only the compat app");
+
+my $app = $zdcf->application(); # default for compat
+isa_ok($app, "ZMQ::Declare::Application");
+$app = $zdcf->application(""); # using explicit name
+isa_ok($app, "ZMQ::Declare::Application");
+
+my @devices = $app->device_names;
is(scalar(@devices), 2, 'Number of available devices');
is_deeply(\@devices, [qw(weather_client weather_server)]);
foreach my $device_name (qw(weather_client weather_server)) {
- my $device = $zdcf->device($device_name);
+ my $device = $app->device($device_name);
isa_ok($device, "ZMQ::Declare::Device");
is($device->name, $device_name);
- is("" . $device->spec, "$zdcf", "parent spec/zdcf is same ref");
+ is("" . $device->application, "$app", "parent app is same ref");
is($device->typename, $device_name =~ /client/ ? "myweatherclientdevice" : "myweatherserverdevice");
}
-my $srv_device = $zdcf->device("weather_server");
+my $srv_device = $app->device("weather_server");
SCOPE: {
my $rt = $srv_device->make_runtime();
isa_ok($rt, "ZMQ::Declare::Device::Runtime");

0 comments on commit 9ec71ce

Please sign in to comment.