public void TestAwaitExternalTaskThrows()
        {
            Coroutine routine = new Coroutine(() => AwaitExternalTask());

            CoroutineBehaviorException ex = Assert.Throws <CoroutineBehaviorException>(() => routine.Resume());

            Assert.Same(ex, routine.FaultingException);

            AssertCoroutineFinished(routine, CoroutineStatus.Faulted);
        }
        public void TestNoAwaitThrows()
        {
            Coroutine routine = new Coroutine(async() => YieldProxy());

            CoroutineBehaviorException ex = Assert.Throws <CoroutineBehaviorException>(() => routine.Resume());

            Assert.Same(ex, routine.FaultingException);

            AssertCoroutineFinished(routine, CoroutineStatus.Faulted);
        }
        public void TestBadBehavior()
        {
            Coroutine routine = new Coroutine(() => BadBehaviorTest());

            routine.Resume();
            routine.Resume();

            CoroutineBehaviorException ex = Assert.Throws <CoroutineBehaviorException>(() => routine.Dispose());

            Assert.Same(ex, routine.FaultingException);

            AssertCoroutineFinished(routine, CoroutineStatus.Faulted);

            Assert.True(_beforeLastYield);
            Assert.False(_afterLastYield);
            Assert.False(_executedFinally4);
        }