public IEnumerator StopCoroutine_Successfully()
        {
            const int testValue1 = 5;

            var coroutine = _coroutineService.StartCoroutine(TestCoroutine(testValue1));

            _coroutineService.StopCoroutine(coroutine);

            Assert.AreNotEqual(testValue1, _testValue);

            yield return(new WaitForSeconds(0.1f));

            Assert.AreNotEqual(testValue1, _testValue);
        }
Ejemplo n.º 2
0
        public void CoroutineService_StopCoroutine_StopsCoroutine()
        {
            bool didComplete = false;

            IEnumerator RunCoroutine()
            {
                yield return(null);

                yield return(null);

                didComplete = true;
            }

            var coroutineService = new CoroutineService();
            var coroutine        = coroutineService.StartCoroutine(RunCoroutine());

            coroutineService.TickCoroutines();
            coroutineService.StopCoroutine(coroutine);
            coroutineService.TickCoroutines();

            Assert.AreEqual(0, coroutineService.NumScheduledCoroutines, "Coroutine did not stop properly");
            Assert.IsFalse(didComplete, "Coroutine did not stop properly");
        }