示例#1
0
        public void RunningACoroutineFromEverywhereShouldPropagateExceptions()
        {
            var coroutine = new ExeCoRoutine();

            coroutine.Enumerable = ExecuteAndThrowAfterInitialization().GetEnumerator();

            var target = new CoroutinesManager();

            target.TestInitialize();
            RunnerFactory.Initialize(() => target);

            target.Start();
            var parent = Task.Run(() =>
            {
                var task = CoroutineResult.WaitForCoroutine(coroutine);
                task.Wait();
            });

            Exception expected = null;

            try
            {
                parent.Wait();
            }
            catch (Exception ex)
            {
                expected = ex;
            }
            target.Stop();

            Assert.IsNotNull(expected);
        }
示例#2
0
        public void RunningACoroutineFromEverywhere()
        {
            var coroutine = new ExeCoRoutine();

            coroutine.Enumerable = Execute().GetEnumerator();

            var target = new CoroutinesManager();

            target.TestInitialize();
            RunnerFactory.Initialize(() => target);

            target.Start();
            var parent = Task.Run(() =>
            {
                var task = CoroutineResult.WaitForCoroutine(coroutine);
                task.Wait();
            });

            parent.Wait();
            target.Stop();

            Assert.AreEqual(1, coroutine.Cycles);
        }