public IEnumerator CoroutineService_WaitForNextTick_WaitsForNextFrame_WithServiceRunner() { bool didComplete = false; using (CoroutineServiceRunner serviceRunner = new GameObject() .AddComponent <CoroutineServiceRunner>()) { var coroutineService = new CoroutineService(); serviceRunner.SetCoroutineService(coroutineService); IEnumerator RunCoroutine() { yield return(coroutineService.WaitForNextTick()); didComplete = true; } coroutineService.StartCoroutine(RunCoroutine()); // This test will complete before ServiceRunner receives it's first update, depending on order of execution yield return(null); yield return(null); Assert.IsTrue(didComplete, "Coroutine did not complete"); } }
public void CoroutineService_WaitForNextTick_CompletesCoroutineAfterNextTicks() { bool didComplete = false; var coroutineService = new CoroutineService(); IEnumerator RunCoroutine() { yield return(coroutineService.WaitForNextTick()); didComplete = true; }; coroutineService.StartCoroutine(RunCoroutine()); coroutineService.TickCoroutines(); Assert.IsTrue(didComplete, "Did not complete"); }