コード例 #1
0
        public void CoroutineRunner_BeforePumpAdvances_NoFrameIsExecuted()
        {
            var pump = new TestPump();

            int i = 0;

            var runner = new CoroutineRunner(TestRoutine(), pump);

            Assert.That(i, Is.EqualTo(0));

            IEnumerator TestRoutine()
            {
                i = 1;
                yield return(null);
            }
        }
コード例 #2
0
        public void PumpMustHandlleExceptionsInCoroutine()
        {
            using (var pump = new TestPump())
            {
                var runner = new CoroutineRunner(Routine(), pump);

                // frame 1
                Assert.DoesNotThrow(() => pump.Advance());

                // frame 2
                Assert.Throws <NotImplementedException>(() => pump.Advance());
            }

            IEnumerator Routine()
            {
                yield return(null);

                throw new NotImplementedException("Second frame");
            }
        }