public void CoroutineThreadEachStepShouldAdvanceOfOneTheCoroutines() { var ct = new CoroutineTestThread(); ct.Initialize(); var cr = new CounterCoroutine(); ct.AddCoroutine(cr); //Initialize step ct.StepForward(); //Run ct.StepForward(); Assert.AreEqual(1, cr.Counter); ct.StepForward(); Assert.AreEqual(2, cr.Counter); }
public void CoroutineThreadAfterTerminationShouldNotExistsTheCoroutine() { var ct = new CoroutineTestThread(); ct.Initialize(); var cr = new CounterCoroutine(); ct.AddCoroutine(cr); //Initialize step ct.StepForward(); while (cr.Counter < 10) { ct.StepForward(); } Assert.AreEqual(10, cr.Counter); ct.StepForward(); ct.StepForward(); Assert.AreEqual(10, cr.Counter); Assert.AreEqual(1, ct.StartedCoroutines); Assert.AreEqual(1, ct.TerminatedCoroutines); }
public void CoroutineThreadExceptionShouldBeHandledTerminatingThread() { var ct = new CoroutineTestThread(); ct.Initialize(); var cr = new CounterCoroutine(new Exception()); ct.AddCoroutine(cr); //Initialize step ct.StepForward(); while (cr.Counter < 10) { ct.StepForward(); } Assert.AreEqual(10, cr.Counter); ct.StepForward(); ct.StepForward(); Assert.AreEqual(10, cr.Counter); Assert.AreEqual(1, cr.InvokedOnError); Assert.AreEqual(1, ct.StartedCoroutines); Assert.AreEqual(1, ct.TerminatedCoroutines); }