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"); } }
public void CoroutineRunner_WhenPumpAdvances_NextFrameIsExecuted() { var pump = new TestPump(); int i = 0; var runner = new CoroutineRunner(TestRoutine(), pump); pump.Advance(); Assert.That(i, Is.EqualTo(1)); pump.Advance(); Assert.That(i, Is.EqualTo(10)); IEnumerator TestRoutine() { i = 1; yield return(null); i = 10; } }