1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 9;
7use Test::Exception;
8
9BEGIN { 
10    use_ok('Tree::Simple::VisitorFactory');
11}
12
13can_ok("Tree::Simple::VisitorFactory", 'new');
14
15my $vf = Tree::Simple::VisitorFactory->new();
16isa_ok($vf, 'Tree::Simple::VisitorFactory');
17
18# test instance method
19{
20    can_ok($vf, 'get');
21    my $visitor = $vf->get("PathToRoot");
22    isa_ok($visitor, 'Tree::Simple::Visitor::PathToRoot');
23}
24
25# test class method
26{
27    can_ok("Tree::Simple::VisitorFactory", 'getVisitor');
28    my $visitor = Tree::Simple::VisitorFactory->getVisitor("FindByPath");
29    isa_ok($visitor, 'Tree::Simple::Visitor::FindByPath');
30}
31
32# test a few error conditions
33
34throws_ok { 
35    Tree::Simple::VisitorFactory->get();
36} qr/Insufficient Arguments/, '... this should die';
37
38throws_ok {
39    $vf->getVisitor("ThisVisitorDoesNotExist");
40} qr/Illegal Operation/, '... this should die';