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

            int i = 0;
            int c = 0;

            queue.Enqueue(
                Cmd.Repeat(5,
                           Cmd.Do(() => ++ i),
                           Cmd.While(() => i % 5 != 0,
                                     Cmd.Do(() => ++ i),
                                     Cmd.WaitForFrames(1),
                                     Cmd.Do(() => ++ c)
                                     ),
                           Cmd.WaitForFrames(1)
                           )
                );

            System.Action Update5 = () => {
                for (int j = 0; j < 5; ++j)
                {
                    queue.Update(0f);
                }
            };

            Update5();
            Assert.AreEqual(i, 5);
            Assert.AreEqual(c, 4);

            Update5();
            Assert.AreEqual(i, 10);
            Assert.AreEqual(c, 8);

            Update5();
            Assert.AreEqual(i, 15);
            Assert.AreEqual(c, 12);

            Update5();
            Assert.AreEqual(i, 20);
            Assert.AreEqual(c, 16);

            Update5();
            Assert.AreEqual(i, 25);
            Assert.AreEqual(c, 20);
        }