public void testStatefulSeq(){ _log.enterScope("testStatefulSeq"); bool first = true; var foo = new StatefulSequence (new BehaviorAction(delegate(){ if(first){ return BehaviorReturnCode.Success; }else{ return BehaviorReturnCode.Failure; } }),new BehaviorAction( delegate(){ if(first){ first = false; return BehaviorReturnCode.Running; }else{ return BehaviorReturnCode.Success; } }),new BehaviorAction(delegate(){ return BehaviorReturnCode.Success; })); Verify.VerifyEquals ("1st running", true, foo.Behave (), BehaviorReturnCode.Running); Verify.VerifyEquals ("2nd success", true, foo.Behave (), BehaviorReturnCode.Success); Verify.VerifyEquals ("3rd failure", true, foo.Behave (), BehaviorReturnCode.Failure); _log.logMessage ("restting first"); first = true; Verify.VerifyEquals ("after reset running", true, foo.Behave (), BehaviorReturnCode.Running); Verify.VerifyEquals ("final success", true, foo.Behave (), BehaviorReturnCode.Success); Verify.VerifyEquals ("final failure", true, foo.Behave (), BehaviorReturnCode.Failure); _log.exitScope (); }
public void TestStatefulSeq(){ //_log.enterScope("testStatefulSeq"); bool first = true; var foo = new StatefulSequence (new BehaviorAction(delegate(){ if(first){ return BehaviorReturnCode.Success; }else{ return BehaviorReturnCode.Failure; } }),new BehaviorAction( delegate(){ if(first){ first = false; return BehaviorReturnCode.Running; }else{ return BehaviorReturnCode.Success; } }),new BehaviorAction(delegate(){ return BehaviorReturnCode.Success; })); Assert.That ( foo.Behave ()== BehaviorReturnCode.Running); Assert.That ( foo.Behave ()== BehaviorReturnCode.Success); Assert.That ( foo.Behave ()== BehaviorReturnCode.Failure); first = true; Assert.That ( foo.Behave ()== BehaviorReturnCode.Running); Assert.That ( foo.Behave ()== BehaviorReturnCode.Success); Assert.That ( foo.Behave ()== BehaviorReturnCode.Failure); }