Esempio n. 1
0
 // throws InterruptedException
 public virtual void testEventTiming()
 {
     Logger l = new Logger();
     l.log(new Event(null,null));
     Thread.Sleep(100);
     l.log(new Event(null,null));
     Assertion.AssertTrue(l.getElapsedTime() >= 0);
 }
        // throws VisitFailure
        public virtual void testTopDownUntil()
        {
            IVisitor stopAt = new SucceedAtNodes(n1, n2);

            Logger expected = new Logger();
            expected.log(new Event(stopAt, n0));
            expected.log(new Event(stopAt, n1));
            expected.log(new Event(stopAt, n2));

            IVisitable nodeReturned =
                DoWhileSuccess.TopDownUntil(logVisitor(stopAt)).visit(n0);

            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
 // throws VisitFailure
 public virtual void testSucceedAtSomeNode()
 {
     IVisitor v = new FailAtNodes(n1,n2);
     (logVisitor(v)).visit(n0);
     Logger expected = new Logger();
     expected.log(new Event(v,n0));
     Assertion.AssertEquals(expected,logger);
 }
        // throws VisitFailure
        public virtual void testTrue()
        {
            Logger expected = new Logger();
            expected.log( new Event( idTrue, n0 ) );

            IVisitable nodeReturned = new IfThenElse( new Identity(), logVisitor(idTrue), logVisitor(idFalse)).visit(n0);

            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
 // throws VisitFailure
 public virtual void testFailAtSomeNodes()
 {
     ArrayList nodes = new ArrayList();
     nodes.Add(n0);
     nodes.Add(n1);
     nodes.Add(n11);
     IVisitor v = new FailAtNodes(nodes);
     new Not((logVisitor(v))).visit(n0);
     new Not((logVisitor(v))).visit(n1);
     (logVisitor(v)).visit(n2);
     new Not((logVisitor(v))).visit(n11);
     (logVisitor(v)).visit(n12);
     Logger expected = new Logger();
     expected.log(new Event(v,n0));
     expected.log(new Event(v,n1));
     expected.log(new Event(v,n2));
     expected.log(new Event(v,n11));
     expected.log(new Event(v,n12));
     Assertion.AssertEquals(expected,logger);
 }
        // throws VisitFailure
        public virtual void testDoWhileSuccess()
        {
            IVisitor condition = new FailAtNodes(n1, n2);
            IVisitor action = new Identity();

            Logger expected = new Logger();
            expected.log(new Event(condition, n0));
            expected.log(new Event(action, n0));
            expected.log(new Event(condition, n1));
            expected.log(new Event(condition, n2));

            IVisitable nodeReturned =
                new DoWhileSuccess(
                logVisitor(condition),
                logVisitor(action)).visit(
                n0);

            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
        // throws VisitFailure
        public virtual void testTopDownUntilAtBorder()
        {
            IVisitor stopAt = new SucceedAtNodes(n1, n2);

            Logger expected = new Logger();

            IVisitor borderAction = new Identity();

            expected.log(new Event(stopAt, n0));
            expected.log(new Event(stopAt, n1));
            expected.log(new Event(borderAction, n1));
            expected.log(new Event(stopAt, n2));
            expected.log(new Event(borderAction, n2));

            IVisitable nodeReturned =
                new TopDownUntil(logVisitor(stopAt),
                logVisitor(borderAction)
                ).visit(n0);

            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n0, nodeReturned);
        }
 // throws VisitFailure
 public virtual void testFailAtSomeNode()
 {
     IVisitor v = new FailAtNodes(n0,n1);
     try
     {
         (logVisitor(v)).visit(n0);
         Assertion.Fail("VisitFailure should have occured");
     }
     catch (VisitFailure)
     {
         Logger expected = new Logger();
         expected.log(new Event(v,n0));
         Assertion.AssertEquals(expected,logger);
     }
 }
        // throws VisitFailure
        public virtual void testTrueFailingThen()
        {
            Fail failingThen = new Fail();
            Logger expected = new Logger();
            expected.log( new Event( failingThen, n0 ) );

            try
            {
                nodeReturned = new IfThenElse( new Identity(), logVisitor(failingThen),	logVisitor(idFalse)).visit(n0);
                Assertion.Fail();
            }
            catch(VisitFailure)
            {
                Assertion.AssertEquals("trace", expected, logger);
                Assertion.AssertNull("returned node", nodeReturned);
            }
        }
Esempio n. 10
0
        // throws jjtraveler.VisitFailure
        public virtual void testStopDownUp()
        {
            Identity downId = new Identity();
            Identity upId = new Identity();
            Identity stopId = new Identity();

            Logger expected = new Logger();
            expected.log( new Event(downId, n4) );
            expected.log( new Event(stopId, n4) );
            expected.log( new Event(upId, n4) );

            IVisitor  visitor = new DownUp(
                logVisitor(downId), logVisitor(stopId), logVisitor(upId) );

            IVisitable nodeReturned = visitor.visit(n4);
            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n4, nodeReturned);
        }
Esempio n. 11
0
        // throws VisitFailure
        public virtual void testSequence()
        {
            Identity id1 = new Identity();
            Identity id2 = new Identity();

            Logger expected = new Logger();
            expected.log( new Event(id1, n0) );
            expected.log( new Event(id2, n0) );

            Sequence  ls = new Sequence( logVisitor(id1), logVisitor(id2) );

            IVisitable nodeReturned = ls.visit(n0);

            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(nodeReturned, n0);
        }
Esempio n. 12
0
        // throws jjtraveler.VisitFailure
        public virtual void testNonStopDownUp()
        {
            Identity downId = new Identity();
            Identity upId = new Identity();
            Fail stop = new Fail();

            Logger expected = new Logger();
            expected.log( new Event(downId, n3) );
            expected.log( new Event(downId, n0) );
            expected.log( new Event(upId, n0) );
            expected.log( new Event(downId, n1) );
            expected.log( new Event(upId, n1) );
            expected.log( new Event(upId, n3) );

            IVisitor  visitor = new DownUp(
                logVisitor(downId), stop, logVisitor(upId) );

            IVisitable nodeReturned = visitor.visit(n3);
            Assertion.AssertEquals(expected, logger);
            Assertion.AssertEquals(n3, nodeReturned);
        }