Example #1
0
        public void CoroutineService_TickCoroutines_TicksFixedScheduledCoroutine()
        {
            bool isCompleted = false;

            var coroutineService = new CoroutineService();

            IEnumerator RunCoroutine()
            {
                yield return(coroutineService.WaitForFixedTick());

                isCompleted = true;
            }

            coroutineService.StartCoroutine(RunCoroutine());

            coroutineService.TickFixedCoroutines();

            Assert.IsTrue(isCompleted, "Coroutine did not complete");
        }
Example #2
0
        public void CoroutineService_WaitForFixedTick_CompletesCoroutineAfterFixedTick()
        {
            bool didComplete = false;

            var coroutineService = new CoroutineService();

            IEnumerator RunCoroutine()
            {
                yield return(coroutineService.WaitForFixedTick());

                didComplete = true;
            };

            coroutineService.StartCoroutine(RunCoroutine());

            coroutineService.TickFixedCoroutines();

            Assert.IsTrue(didComplete, "Did not complete");
        }
        public IEnumerator CoroutineService_WaitForFixedTick_WaitsForFixedUpdate_WithServiceRunner()
        {
            bool didComplete = false;

            using (CoroutineServiceRunner serviceRunner = new GameObject()
                                                          .AddComponent <CoroutineServiceRunner>())
            {
                var coroutineService = new CoroutineService();
                serviceRunner.SetCoroutineService(coroutineService);

                IEnumerator RunCoroutine()
                {
                    yield return(coroutineService.WaitForFixedTick());

                    didComplete = true;
                }

                coroutineService.StartCoroutine(RunCoroutine());

                yield return(new WaitForFixedUpdate());

                Assert.IsTrue(didComplete, "Coroutine did not complete");
            }
        }