File: 10_Tree_Simple_VisitorFactory_test.t

package info (click to toggle)
libtree-simple-visitorfactory-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 412 kB
  • sloc: perl: 3,167; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 9;
use Test::Exception;

BEGIN { 
    use_ok('Tree::Simple::VisitorFactory');
}

can_ok("Tree::Simple::VisitorFactory", 'new');

my $vf = Tree::Simple::VisitorFactory->new();
isa_ok($vf, 'Tree::Simple::VisitorFactory');

# test instance method
{
    can_ok($vf, 'get');
    my $visitor = $vf->get("PathToRoot");
    isa_ok($visitor, 'Tree::Simple::Visitor::PathToRoot');
}

# test class method
{
    can_ok("Tree::Simple::VisitorFactory", 'getVisitor');
    my $visitor = Tree::Simple::VisitorFactory->getVisitor("FindByPath");
    isa_ok($visitor, 'Tree::Simple::Visitor::FindByPath');
}

# test a few error conditions

throws_ok { 
    Tree::Simple::VisitorFactory->get();
} qr/Insufficient Arguments/, '... this should die';

throws_ok {
    $vf->getVisitor("ThisVisitorDoesNotExist");
} qr/Illegal Operation/, '... this should die';