示例#1
0
        public void NappingTestsDontCountTowardsLimit( )
        {
            int i = 0;

            um = new UnityManager(1);
            ActionTask task = new ActionTask((_) => _.IsNapping = true, false);

            task.Extend((_) => i = 100);
            um.EnqueueTask(task);
            for (int j = 0; j < 5; j++)
            {
                ITask t = new ActionTask((_) => i++, false);
                um.EnqueueTask(t);
            }
            um.UnsafeUpdate();
            Assert.IsTrue(task.IsNapping, "Task didn't start napping.");
            for (int j = 0; j < 5; j++)
            {
                um.UnsafeUpdate();
                Assert.AreEqual(j + 1, i, "Didn't just run 1.");
            }
            task.IsNapping = false;
            um.UnsafeUpdate();
            Assert.AreEqual(100, i, "Didn't run awakened task.");
        }
示例#2
0
        public void CanRunSomething( )
        {
            int   i    = 0;
            ITask task = new ActionTask((_) => i = 5, false);

            um.EnqueueTask(task);
            um.UnsafeUpdate();

            Assert.IsTrue(task.IsCompleted, "Task never completed.");
            Assert.AreEqual(5, i, "Task thought it completed, but did not run");
        }
示例#3
0
        public void CanLimitTasksPerUpdate( )
        {
            int i = 0;

            um = new UnityManager(2);
            for (int j = 0; j < 5; j++)
            {
                ITask task = new ActionTask((_) => i++, false);
                um.EnqueueTask(task);
            }
            um.UnsafeUpdate();
            Assert.AreEqual(2, i, "Didn't just run 2.");
            um.UnsafeUpdate();
            Assert.AreEqual(4, i, "Didn't just run 2.");
            um.UnsafeUpdate();
            Assert.AreEqual(5, i, "Didn't run last one correctly.");

            i  = 0;
            um = new UnityManager(1);
            for (int j = 0; j < 5; j++)
            {
                ITask task = new ActionTask((_) => i++, false);
                um.EnqueueTask(task);
            }
            for (int j = 0; j < 5; j++)
            {
                um.UnsafeUpdate();
                Assert.AreEqual(j + 1, i, "Didn't just run 1.");
            }
        }