diff _test/Test/DOM/Navigator.pm @ 13:bb8d67f811ea

merge heads
author Sergey
date Wed, 02 Sep 2009 23:11:14 +0400
parents 75980091813b
children 7f00786f8210
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_test/Test/DOM/Navigator.pm	Wed Sep 02 23:11:14 2009 +0400
@@ -0,0 +1,71 @@
+package Test::DOM::Navigator;
+use base qw(IMPL::Test::Unit);
+
+__PACKAGE__->PassThroughArgs;
+
+use IMPL::Test qw(test failed);
+use IMPL::DOM::Navigator;
+use IMPL::DOM::Node;
+
+test Creation => sub {
+    my ($this) = @_;
+    
+    my $doc = new IMPL::DOM::Node(nodeName => 'root');
+    
+    my $obj = new IMPL::DOM::Navigator($doc) or failed "Failed to create instance" ;
+};
+
+test Navigate => sub {
+    my $doc = new IMPL::DOM::Node(nodeName => 'root');
+    my $child = $doc->insertNode(
+        new IMPL::DOM::Node(
+            nodeName => 'Child'
+        )
+    );
+    
+    my $navi = new IMPL::DOM::Navigator($doc);
+    my $navresult = $navi->Navigate("Child");
+    
+    failed ("Navigate retuned unexpected result", "Recieved: $navresult", "Expected: $child") if $child != $navresult;
+    my $curr = $navi->Current;
+    failed ("Current node has a wrong value","Current: $curr","Expected: $child") if $child != $curr;
+};
+
+test PathToString => sub {
+    my $doc = new IMPL::DOM::Node(nodeName => 'root');
+    my $child = $doc->insertNode(
+        new IMPL::DOM::Node(
+            nodeName => 'Child'
+        )
+    );
+    
+    my $navi = new IMPL::DOM::Navigator($doc);
+    $navi->Navigate("Child");
+    
+    my $expected = "root/Child";
+    my $res = $navi->PathToString;
+    failed("Unexpected PathToString result","Recieved: $res","Expected: $expected") if $res ne $expected;
+};
+
+test Back => sub {
+    my $doc = new IMPL::DOM::Node(nodeName => 'root');
+    my $child = $doc->insertNode(
+        new IMPL::DOM::Node(
+            nodeName => 'Child'
+        )
+    );
+    
+    my $navi = new IMPL::DOM::Navigator($doc);
+    $navi->Navigate("Child");
+    my $navresult = $navi->Back;
+    
+    failed ("Back() retuned unexpected result", "Recieved: $navresult", "Expected: $doc") if $doc != $navresult;
+    my $curr = $navi->Current;
+    failed ("Current node has a wrong value","Current: $curr","Expected: $doc") if $doc != $curr;
+};
+
+
+
+
+
+1;