Esempio n. 1
0
		public void test_query_0 ()
		{
			bool loadResult = testAgent.btload("node_test/query_subtree_0");
			if(!loadResult)
			{
				Debug.LogError("node_test/query_subtree_0 " + "load failed!");
				Assert.Fail();
			}

			loadResult = testAgent.btload("node_test/query_subtree_1");
			if(!loadResult)
			{
				Debug.LogError("node_test/query_subtree_1 " + "load failed!");
				Assert.Fail();
			}

			loadResult = testAgent.btload("node_test/query_subtree_2");
			if(!loadResult)
			{
				Debug.LogError("node_test/query_subtree_2 " + "load failed!");
				Assert.Fail();
			}

			testAgent.btsetcurrent("node_test/query_ut_0");
			testAgent.resetProperties();

			behaviac.EBTStatus status = testAgent.btexec();
//			status = testAgent.btexec();
//			status = testAgent.btexec();
			
			Assert.AreEqual(1, testAgent.testVar_0);
			Assert.AreEqual(behaviac.EBTStatus.BT_SUCCESS, status);
		}
Esempio n. 2
0
        public void test_parallel_0()
        {
            testAgent.btsetcurrent("node_test/parallel_ut_0");
            testAgent.resetProperties();
            testAgent.btexec();

            Assert.AreEqual(2, testAgent.testVar_0);
        }
Esempio n. 3
0
        public void test_event_0()
        {
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.resetProperties();

            testAgent.FireEvent("event_test_void");
            behaviac.EBTStatus status = testAgent.btexec();

            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.FireEvent("event_test_void");
            Assert.AreEqual(true, testAgent.event_test_var_bool);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.FireEvent("event_test_int", 13);
            Assert.AreEqual(13, testAgent.event_test_var_int);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.FireEvent("event_test_int_bool", 15, true);
            Assert.AreEqual(true, testAgent.event_test_var_bool);
            Assert.AreEqual(15, testAgent.event_test_var_int);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.FireEvent("event_test_int_bool_float", 15, true, 27.3f);
            Assert.AreEqual(true, testAgent.event_test_var_bool);
            Assert.AreEqual(15, testAgent.event_test_var_int);
            Assert.AreEqual(27.3f, testAgent.event_test_var_float);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.testVar_0 = 0;
            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_SUCCESS, status);
            Assert.AreEqual(0, testAgent.testVar_1);

            testAgent.FireEvent("event_test_int_bool_float", 19, true, 11.9f);
            Assert.AreEqual(false, testAgent.event_test_var_bool);
            Assert.AreEqual(-1, testAgent.event_test_var_int);
            Assert.AreEqual(-1.0f, testAgent.event_test_var_float);
        }
Esempio n. 4
0
        public void test_enter_exit_action_0()
        {
            testAgent.btsetcurrent("node_test/enter_exit_action_ut_0");
            testAgent.resetProperties();

            behaviac.EBTStatus status = testAgent.btexec();
            //Assert.AreEqual(1, testAgent.action_0_enter_count);
            Assert.AreEqual(1, testAgent.action_1_enter_count);
            Assert.AreEqual(1, testAgent.action_2_enter_count);
            Assert.AreEqual("enter_test", testAgent.testVar_str_0);

            //Assert.AreEqual(0, testAgent.action_0_exit_count);
            Assert.AreEqual(0, testAgent.action_1_exit_count);
            Assert.AreEqual(0, testAgent.action_2_exit_count);

            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);
            int loopCount = 1000;

            while (loopCount > 0)
            {
                status = testAgent.btexec();
                //Assert.AreEqual(1, testAgent.action_0_enter_count);
                Assert.AreEqual(1, testAgent.action_1_enter_count);
                Assert.AreEqual(1, testAgent.action_2_enter_count);

                //Assert.AreEqual(0, testAgent.action_0_exit_count);
                Assert.AreEqual(0, testAgent.action_1_exit_count);
                Assert.AreEqual(0, testAgent.action_2_exit_count);

                Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);
                --loopCount;
            }

            //
            testAgent.testVar_0 = 0;
            status = testAgent.btexec();
            //Assert.AreEqual(1, testAgent.action_0_enter_count);
            Assert.AreEqual(1, testAgent.action_1_enter_count);
            Assert.AreEqual(1, testAgent.action_2_enter_count);
            Assert.AreEqual("exit_test", testAgent.testVar_str_0);

            //Assert.AreEqual(1, testAgent.action_0_exit_count);
            Assert.AreEqual(1, testAgent.action_1_exit_count);
            Assert.AreEqual(1, testAgent.action_2_exit_count);

            Assert.AreEqual(behaviac.EBTStatus.BT_SUCCESS, status);

            loopCount = 100;

            while (loopCount > 0)
            {
                status = testAgent.btexec();
                --loopCount;
            }

            //Assert.AreEqual(101, testAgent.action_0_enter_count);
            Assert.AreEqual(101, testAgent.action_1_enter_count);
            Assert.AreEqual(101, testAgent.action_2_enter_count);

            //Assert.AreEqual(101, testAgent.action_0_exit_count);
            Assert.AreEqual(101, testAgent.action_1_exit_count);
            Assert.AreEqual(101, testAgent.action_2_exit_count);

            Assert.AreEqual(behaviac.EBTStatus.BT_SUCCESS, status);
        }
Esempio n. 5
0
        public void test_decoration_loop_0()
        {
            testAgent.btsetcurrent("node_test/decoration_loop_ut_0");

            int loopCount = 1000;

            while (loopCount > 0)
            {
                testAgent.resetProperties();
                testAgent.btexec();
                Assert.AreEqual(0, testAgent.testVar_0);
                --loopCount;
            }
        }
Esempio n. 6
0
        public void test_decoration_loop_0()
        {
            testAgent.btsetcurrent("node_test/decoration_loop_ut_0");

            int loopCount = 1000;

            while (loopCount > 0)
            {
                testAgent.resetProperties();

                behaviac.EBTStatus status = testAgent.btexec();

                Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);
                Assert.AreEqual(0, testAgent.testVar_0);

                behaviac.BehaviorTreeTask btTask = testAgent.btgetcurrent();
                Assert.AreNotEqual(null, btTask);

                List <behaviac.BehaviorTask> nodes = btTask.GetRunningNodes(false);
                Assert.AreEqual(3, nodes.Count);

                List <behaviac.BehaviorTask> leaves = btTask.GetRunningNodes(true);
                Assert.AreEqual(0, leaves.Count);

                --loopCount;
            }
        }
Esempio n. 7
0
        public void test_event_0()
        {
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.resetProperties();

            behaviac.EBTStatus status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.FireEvent("event_test_void");
            Assert.AreEqual(true, testAgent.event_test_var_bool);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.btexec();

            behaviac.Workspace.Instance.DoubleValueSinceStartup = 0;
            testAgent.FireEvent("event_test_int", 13);
            Assert.AreEqual(13, testAgent.event_test_var_int);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            behaviac.Workspace.Instance.DoubleValueSinceStartup = 5.1 * 1000;
            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.btexec();
            testAgent.FireEvent("event_test_int_bool", 15, true);
            Assert.AreEqual(true, testAgent.event_test_var_bool);
            Assert.AreEqual(15, testAgent.event_test_var_int);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.btexec();
            testAgent.FireEvent("event_test_int_bool_float", 15, true, 27.3f);
            Assert.AreEqual(true, testAgent.event_test_var_bool);
            Assert.AreEqual(15, testAgent.event_test_var_int);
            Assert.AreEqual(27.3f, testAgent.event_test_var_float);

            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.btexec();
            testAgent.testVar_0 = 0;
            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_SUCCESS, status);
            Assert.AreEqual(0, testAgent.testVar_1);

            testAgent.FireEvent("event_test_int_bool_float", 19, true, 11.9f);
            Assert.AreEqual(false, testAgent.event_test_var_bool);
            Assert.AreEqual(-1, testAgent.event_test_var_int);
            Assert.AreEqual(-1.0f, testAgent.event_test_var_float);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            Assert.AreEqual(null, testAgent.event_test_var_agent);
            testAgent.FireEvent("event_test_agent", testAgent);
            Assert.AreNotEqual(null, testAgent.event_test_var_agent);

            testAgent.resetProperties();
            testAgent.btsetcurrent("node_test/event_ut_0");
            testAgent.btresetcurrrent();
            status = testAgent.btexec();
            Assert.AreEqual(behaviac.EBTStatus.BT_RUNNING, status);

            Assert.AreEqual(null, testAgent.event_test_var_agent);
            testAgent.FireEvent("event_test_agent", testChild);
            Assert.AreNotEqual(null, testAgent.event_test_var_agent);
        }
Esempio n. 8
0
        public void test_predicate_selector_0()
        {
            testAgent.btsetcurrent("node_test/predicate_selector_ut_0");
            testAgent.resetProperties();
            behaviac.EBTStatus status = testAgent.btexec();

            Assert.AreEqual(behaviac.EBTStatus.BT_FAILURE, status);
            Assert.AreEqual(0, testAgent.testVar_1);
            Assert.AreEqual(0, testAgent.testVar_0);
        }