public void CoroutineBase_ShouldStopOnException()
        {
            Exception throws = null;
            var       cr     = new CoroutineBaseFake();
            var       en     = cr.Execute().GetEnumerator();

            en.MoveNext();
            en.MoveNext();

            Assert.AreEqual(4, cr.Called.Count);
            cr.Throws = new Exception();
            try
            {
                en.MoveNext();
            }
            catch (Exception ex)
            {
                throws = ex;
            }

            Assert.AreEqual(throws, cr.Throws);
            Assert.AreEqual(6, cr.Called.Count);
            Assert.AreEqual("OnEndOfCycle", cr.Called[4]);
            Assert.AreEqual("OnCycle", cr.Called[5]);
        }
        public void CoroutineBase_ShouldBeRunnable()
        {
            var cr = new CoroutineBaseFake();
            var en = cr.Execute().GetEnumerator();

            en.MoveNext();
            Assert.AreEqual(2, cr.Called.Count);
            Assert.AreEqual("Initialize", cr.Called[0]);
            Assert.AreEqual("OnCycle", cr.Called[1]);

            en.MoveNext();
            Assert.AreEqual(4, cr.Called.Count);
            Assert.AreEqual("OnEndOfCycle", cr.Called[2]);
            Assert.AreEqual("OnCycle", cr.Called[3]);
        }
        public void CoroutineBase_ShouldWaitWhenNothingToDo()
        {
            var cr = new CoroutineBaseFake();
            var en = cr.Execute().GetEnumerator();

            en.MoveNext();
            en.MoveNext();

            Assert.AreEqual(4, cr.Called.Count);
            cr.NoRun = true;
            en.MoveNext();
            Assert.AreEqual(CoroutineResult.Wait, en.Current);

            Assert.AreEqual(6, cr.Called.Count);
            Assert.AreEqual("OnEndOfCycle", cr.Called[4]);
            Assert.AreEqual("OnEndOfCycle", cr.Called[5]);
        }