Пример #1
0
        public void TestActionStartupAndUpdate()
        {
            // make some actions
            var a   = new TestAction("a");
            var b   = new TestAction("b");
            var c   = new TestAction("c", true); // this one stops before first update
            var seq = new TestScript("test", a, b, c);

            Assert.IsTrue(a.IsEnqueued && a.IsActive && !a.IsStarted);
            Assert.IsTrue(a.countUpdate == 0);

            // fake an update cycle
            seq.OnUpdate();

            Assert.IsTrue(a.IsEnqueued && a.IsActive && a.IsStarted);
            Assert.IsTrue(a.countUpdate == 1);

            // stop. this will remove and deactivate A, and activate B,
            // but not start it yet until an update
            a.Stop(true);
            Assert.IsTrue(!a.IsEnqueued && !a.IsActive && !a.IsStarted);
            Assert.IsTrue(b.IsEnqueued && b.IsActive && !b.IsStarted);
            Assert.IsTrue(a.countUpdate == 1);
            Assert.IsTrue(b.countUpdate == 0);

            seq.OnUpdate();
            Assert.IsTrue(b.IsEnqueued && b.IsActive && b.IsStarted);
            Assert.IsTrue(b.countUpdate == 1);

            // stop b. this will activate c, which will stop itself before first update
            b.Stop(true);
            Assert.IsTrue(c.IsEnqueued && c.IsActive && !c.IsStarted);
            Assert.IsTrue(c.countUpdate == 0);
            seq.OnUpdate();
            Assert.IsTrue(!c.IsEnqueued && !c.IsActive && !c.IsStarted);
            Assert.IsTrue(c.countUpdate == 0); // this update never got a chance to run
        }
Пример #2
0
        public void TestActionStartupAndUpdate()
        {
            // make some actions
            var a = new TestAction("a");
            var b = new TestAction("b");
            var c = new TestAction("c", true); // this one stops before first update
            var seq = new TestScript("test", a, b, c);

            Assert.IsTrue(a.IsEnqueued && a.IsActive && !a.IsStarted);
            Assert.IsTrue(a.countUpdate == 0);

            // fake an update cycle
            seq.OnUpdate();

            Assert.IsTrue(a.IsEnqueued && a.IsActive && a.IsStarted);
            Assert.IsTrue(a.countUpdate == 1);

            // stop. this will remove and deactivate A, and activate B,
            // but not start it yet until an update
            a.Stop(true);
            Assert.IsTrue(!a.IsEnqueued && !a.IsActive && !a.IsStarted);
            Assert.IsTrue( b.IsEnqueued &&  b.IsActive && !b.IsStarted);
            Assert.IsTrue(a.countUpdate == 1);
            Assert.IsTrue(b.countUpdate == 0);

            seq.OnUpdate();
            Assert.IsTrue(b.IsEnqueued && b.IsActive && b.IsStarted);
            Assert.IsTrue(b.countUpdate == 1);

            // stop b. this will activate c, which will stop itself before first update
            b.Stop(true);
            Assert.IsTrue(c.IsEnqueued && c.IsActive && !c.IsStarted);
            Assert.IsTrue(c.countUpdate == 0);
            seq.OnUpdate();
            Assert.IsTrue(!c.IsEnqueued && !c.IsActive && !c.IsStarted);
            Assert.IsTrue(c.countUpdate == 0); // this update never got a chance to run
        }