Ejemplo n.º 1
0
		public void 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;
					}
				}
			}));
			
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Running);
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Success);
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Failure);
			
			first = true;
			second = true;
			
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Running);
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Success);
			Assert.That ( foo.Behave ()== BehaviorReturnCode.Failure);
			
		}
Ejemplo n.º 2
0
 override protected BehaviorComponent createDefault()
 {
     StatefulSelector statefulSelector = new StatefulSelector();
     return statefulSelector;
 }
Ejemplo n.º 3
0
		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;
					}
				}
			}));

			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 flags");
			first = true;
			second = 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 ();
		}
Ejemplo n.º 4
0
        public void testStatefulSel()
        {
            log.enterScope("testStatefulSel");

            bool first = 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(){
                return BehaviorReturnCode.Success;
            }));

            new VerificationPoint ().VerifyEquals ("1st running", true, foo.Behave (), BehaviorReturnCode.Running);
            new VerificationPoint ().VerifyEquals ("2nd success", true, foo.Behave (), BehaviorReturnCode.Success);
            new VerificationPoint ().VerifyEquals ("3rd success", true, foo.Behave (), BehaviorReturnCode.Success);

            log.logMessage ("restting first");
            first = true;

            new VerificationPoint ().VerifyEquals ("after reset running", true, foo.Behave (), BehaviorReturnCode.Running);
            new VerificationPoint ().VerifyEquals ("final success", true, foo.Behave (), BehaviorReturnCode.Success);

            log.exitScope ();
        }