Example #1
0
        public void OnCurrentTaskExecutingConditionFailed_ExpectedBehavior()
        {
            bool test = false;
            var  ctx  = new MyContext();

            ctx.Init();
            var planner = new Planner <MyContext>();

            planner.OnCurrentTaskExecutingConditionFailed = (t, c) => { test = t.Name == "Sub-task" && c.Name == "TestCondition"; };
            var domain = new Domain <MyContext>("Test");
            var task1  = new Selector()
            {
                Name = "Test"
            };
            var task2 = new PrimitiveTask()
            {
                Name = "Sub-task"
            };

            task2.SetOperator(new FuncOperator <MyContext>((context) => TaskStatus.Continue));
            task2.AddExecutingCondition(new FuncCondition <MyContext>("TestCondition", context => context.Done));
            domain.Add(domain.Root, task1);
            domain.Add(task1, task2);

            planner.Tick(domain, ctx);

            Assert.IsTrue(test);
        }
Example #2
0
        public void AddExecutingCondition_ExpectedBehavior()
        {
            var task = new PrimitiveTask <byte>()
            {
                Name = "Test"
            };
            var t = task.AddExecutingCondition(new FuncCondition <MyContext, byte>("TestCondition", context => context.Done == false));

            Assert.IsTrue(t == task);
            Assert.IsTrue(task.ExecutingConditions.Count == 1);
        }