public void CoroutineCancelTest() { var scheduler = new InterleavedCoroutineScheduler(); var coroutine = new CancelCoroutine(); scheduler.Execute(coroutine); Assert.Equal(0, coroutine.Iteration); scheduler.Update(0.0f); Assert.Equal(1, coroutine.Iteration); coroutine.Cancel(); scheduler.Update(0.0f); Assert.Equal(1, coroutine.Iteration); }
public void CoroutineCancelTest_OtherThread() { var scheduler = new InterleavedCoroutineScheduler(); var coroutine = new CancelCoroutine(); scheduler.Execute(coroutine); Task.Run(async() => { await Task.Delay(100); coroutine.Cancel(); }); while (coroutine.Status == CoroutineStatus.Running) { scheduler.Update(0); } Assert.Equal(CoroutineStatus.Cancelled, coroutine.Status); }