Esempio n. 1
0
        public void CoroutineService_WaitForNumTick_CompletesCoroutineAfterNumTicks()
        {
            bool didComplete = false;

            var coroutineService = new CoroutineService();

            IEnumerator RunCoroutine()
            {
                yield return(coroutineService.WaitForNumTicks(2));

                didComplete = true;
            };

            coroutineService.StartCoroutine(RunCoroutine());

            coroutineService.SetNumTick(10);

            coroutineService.TickCoroutines();

            Assert.IsTrue(didComplete, "Did not complete");
        }
Esempio n. 2
0
        public void CoroutineService_SetNumTick_UpdatesCoroutineTickCount()
        {
            bool isCompleted = false;

            var coroutineService = new CoroutineService();

            IEnumerator RunCoroutine()
            {
                yield return(coroutineService.WaitForNumTicks(10));

                isCompleted = true;
            }

            coroutineService.StartCoroutine(RunCoroutine());

            coroutineService.TickCoroutines(); // Still waits

            Assert.IsFalse(isCompleted, "Coroutine completed too early");

            coroutineService.SetNumTick(10);
            coroutineService.TickCoroutines(); // Completes

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