// throws VisitFailure
        public virtual void testSpineTopDownAtLeaf()
        {
            IVisitor stop = new FailAtNodes(n11);
            SpineTopDown spineTopDown = new SpineTopDown(logVisitor(stop));

            // n11 fails, so path to n12 is first to succeed.
            Logger expected = new Logger(stop, new IVisitable[]{n0,n1,n11,n12});

            IVisitable nodeReturned = spineTopDown.visit(n0);

            Assertion.AssertEquals("visit trace",expected, logger);
            Assertion.AssertEquals("return value",n0, nodeReturned);
        }
        // throws VisitFailure
        public virtual void testSpineTopDownAtInnerNode()
        {
            IVisitor stop = new FailAtNodes(n1);
            SpineTopDown spineTopDown = new SpineTopDown(logVisitor(stop));

            // n1 fails, so searching continues in n2.
            Logger expected = new Logger(stop, new IVisitable[]{n0,n1,n2});

            IVisitable nodeReturned = spineTopDown.visit(n0);

            Assertion.AssertEquals("visit trace",expected, logger);
            Assertion.AssertEquals("return value",n0, nodeReturned);
        }
 public virtual void testSpineTopDownFailAtTop()
 {
     IVisitor stop = new FailAtNodes(n0);
     SpineTopDown spineTopDown = new SpineTopDown(logVisitor(stop));
     Logger expected = new Logger(stop, new IVisitable[]{n0});
     IVisitable nodeReturned = null;
     try
     {
         nodeReturned = spineTopDown.visit(n0);
         Assertion.Fail("VisitFailure should have occured!");
     }
     catch (VisitFailure)
     {
         Assertion.AssertEquals("visit trace",expected, logger);
         Assertion.AssertNull("return value",nodeReturned);
     }
 }
        // throws VisitFailure
        public virtual void testSpineTopDownOnlySuccess()
        {
            IVisitor dontStop = new Identity();
            SpineTopDown spineTopDown = new SpineTopDown(logVisitor(dontStop));

            // First path from n0 to n11 successful -- spinetopdown
            // won't search any further after that.
            Logger expected = new Logger(dontStop, new IVisitable[]{n0,n1,n11});

            IVisitable nodeReturned = spineTopDown.visit(n0);

            Assertion.AssertEquals("visit trace",expected, logger);
            Assertion.AssertEquals("return value",n0, nodeReturned);
        }