public void testStatefulSel() { _log.enterScope("testStatefulSel"); bool first = true; bool second = true; var foo = new StatefulSelector(new BehaviorAction(delegate(){ return(BehaviorReturnCode.Failure); }), new BehaviorAction(delegate() { if (first) { first = false; return(BehaviorReturnCode.Running); } else { return(BehaviorReturnCode.Failure); } }), new BehaviorAction(delegate(){ if (first) { return(BehaviorReturnCode.Success); } else { if (second) { second = false; return(BehaviorReturnCode.Success); } else { return(BehaviorReturnCode.Failure); } } })); VerificationPoint.VerifyEquals("1st running", true, foo.Behave(), BehaviorReturnCode.Running); VerificationPoint.VerifyEquals("2nd success", true, foo.Behave(), BehaviorReturnCode.Success); VerificationPoint.VerifyEquals("3rd failure", true, foo.Behave(), BehaviorReturnCode.Failure); _log.logMessage("restting flags"); first = true; second = true; VerificationPoint.VerifyEquals("after reset running", true, foo.Behave(), BehaviorReturnCode.Running); VerificationPoint.VerifyEquals("final success", true, foo.Behave(), BehaviorReturnCode.Success); VerificationPoint.VerifyEquals("final failure", true, foo.Behave(), BehaviorReturnCode.Failure); _log.exitScope(); }
public void test1() { _log.enterScope("test1"); var foo = new Sequence(new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); })); VerificationPoint.VerifyEquals("all running is running", true, foo.Behave(), BehaviorReturnCode.Running); foo = new Sequence(new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Running); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Success); })); VerificationPoint.VerifyEquals("all but one running is running", true, foo.Behave(), BehaviorReturnCode.Running); foo = new Sequence(new BehaviorAction(delegate() { return(BehaviorReturnCode.Success); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Success); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Success); }), new BehaviorAction(delegate() { return(BehaviorReturnCode.Success); })); VerificationPoint.VerifyEquals("all success is success", true, foo.Behave(), BehaviorReturnCode.Success); _log.exitScope(); }