Exemplo n.º 1
0
        public void NotWaitingItShouldBePossibleToWaitForEnEntireForEach()
        {
            _notWaitingStarted     = false;
            _notWaitingCompleted   = false;
            _coroutineResultsCount = 0;
            var coroutine = new Mock <ICoroutineThread>();

            coroutine.Setup(a => a.Execute())
            .Returns(NotWaitingForAllResults(10));

            var target = new CoroutinesManager();

            target.TestInitialize();
            var rtt = new RunnerForTest(target);

            target.StartCoroutine(coroutine.Object);

            rtt.RunCycle();             //Coroutine initialized
            Assert.IsTrue(_notWaitingStarted);
            rtt.RunCycle(2);            //Coroutine started
            Assert.IsTrue(_notWaitingCompleted);
            Assert.AreEqual(0, _coroutineResultsCount);

            rtt.RunCycle(50);             //Coroutine started


            Assert.AreEqual(10, _coroutineResultsCount);
        }
Exemplo n.º 2
0
        public void NotWaitingItShouldBePossibleToWaitForATaskToCompleteWithTimeoutError()
        {
            _notWaitingCompleted = false;
            _notWaitingStarted   = false;
            _taskRun             = false;
            _taskStarted         = false;
            _completedTaks       = false;
            _exception           = null;
            var coroutine = new Mock <ICoroutineThread>();

            coroutine.Setup(a => a.Execute())
            .Returns(NotWaitingHavingTimeout());

            var target = new CoroutinesManager();

            target.TestInitialize();
            var rtt = new RunnerForTest(target);

            target.StartCoroutine(coroutine.Object);

            rtt.RunCycle();             //Coroutine initialized
            Assert.IsTrue(_notWaitingStarted);
            rtt.RunCycle(2);            //Coroutine started
            Assert.IsTrue(_notWaitingCompleted);


            Assert.IsTrue(_taskStarted);
            Assert.IsNull(_exception);
            Assert.IsFalse(_completedTaks);

            rtt.RunCycleFor(150);
            Assert.IsTrue(_taskStarted);
            Assert.IsNotNull(_exception);
            Assert.IsFalse(_completedTaks);
        }