Exemplo n.º 1
0
        public static void TestCondition()
        {
            CommandQueue queue = new CommandQueue();

            int testCount            = 0;
            int conditionCalledCount = 0;

            queue.Enqueue(
                Cmd.Repeat(4,
                           Cmd.Condition(() => testCount % 2 == 0,
                                         Cmd.Do(() => testCount += 1),
                                         Cmd.Do(() => {
                Assert.IsTrue(testCount % 2 == 1, "Unexpected state in condition branch.");
                conditionCalledCount += 1;
                testCount            += 1;
            })
                                         )
                           ),
                Cmd.Do(() => Assert.AreEqual(conditionCalledCount, 2))
                );

            while (!queue.Update(DELTA_TIME_RATE))
            {
            }
        }