public void IterateRepeatTest() { Assert.DoesNotThrow(() => { BeginTest(TestEnv0, 4); }); List <int> integers = new List <int>() { 1, 2, 3, 4, 5 }; TaskInfo iterateTask = new TaskInfo { TaskType = TaskType.EvalExpression, Expression = ExpressionInfo.Iterate(integers), OutputsCount = 1, }; TaskInputInfo input = new TaskInputInfo { OutputIndex = 0, OutputTask = iterateTask, }; ExpressionInfo isTrue = ExpressionInfo.Eq( ExpressionInfo.Val(PrimitiveContract.Create(true)), ExpressionInfo.Get( ExpressionInfo.Val(input), ExpressionInfo.PrimitiveVal("IsLast"))); TaskInfo breakIfCompleted = new TaskInfo { TaskType = TaskType.Branch, Expression = isTrue, Children = new[] { new TaskInfo { TaskType = TaskType.Break, }, null } }; TaskInfo repeat = new TaskInfo { TaskType = TaskType.Repeat, Expression = ExpressionInfo.PrimitiveVal(true), Children = new[] { iterateTask, breakIfCompleted, } }; repeat.SetParents(); input.SetScope(); const int playerId = 1; bool isIterated = false; int counter = 0; BeginCleanupCheck(playerId); FinializeTest(playerId, repeat, result => { Assert.IsTrue(isIterated); Assert.AreEqual(TaskState.Completed, result.State); Assert.IsFalse(result.IsFailed); CleanupCheck(playerId); Assert.Pass(); }, childTask => { if (childTask.TaskId == iterateTask.TaskId && childTask.State == TaskState.Completed) { counter++; ITaskMemory memory = m_engine.GetTaskEngine(playerId).Memory; IterationResult iterResult = (IterationResult)memory.ReadOutput(iterateTask.Parent.TaskId, iterateTask.TaskId, 0); if (iterResult.IsLast) { isIterated = true; Assert.IsNull(iterResult.Object); } else { Assert.AreEqual(counter, (int)iterResult.Object); } } }); }