public void ItShouldBePossibleToInvokeCoroutineAndWait()
        {
            var ct    = new CoroutineTestThread();
            var subCr = new LocalInvokerCoroutine();

            subCr.ActionAsTask = true;

            var cr = new LocalInvokerCoroutine();

            cr.Coroutine = subCr;
            ct.Initialize();
            ct.AddCoroutine(cr);
            ct.StepForward();

            for (int i = 0; i < 12; i++)
            {
                ct.StepForward();
                Thread.Sleep(20);
            }

            Thread.Sleep(200);
            Assert.AreEqual(subCr.NormalCalls, 2);
            Assert.AreEqual(subCr.StepFunctionCall, 1);
            Assert.AreEqual("ActionAsTask", subCr.RealResult);


            Assert.AreEqual(cr.NormalCalls, 2);
            Assert.AreEqual(cr.StepFunctionCall, 0);
            Assert.AreEqual("ActionAsTaskTasked", cr.CoroutineResult);
        }
        public void ItShouldBePossibleToInvokeCoroutineStatically()
        {
            var cr = new LocalInvokerCoroutine();

            cr.ActionAsTask = true;

            Coroutine.CallCoroutine(cr.Run());
            Thread.Sleep(200);
            Assert.AreEqual(cr.NormalCalls, 2);
            Assert.AreEqual(cr.StepFunctionCall, 1);
            Assert.AreEqual("ActionAsTask", cr.RealResult);
        }
        public void ItShouldBePossibleToInvokeLocalAndWaitWithReturnValues()
        {
            var          ct     = new CoroutineTestThread();
            const string result = "TestResult";
            var          cr     = new LocalInvokerCoroutine(result);

            ct.Initialize();
            ct.AddCoroutine(cr);
            ct.StepForward();

            for (int i = 0; i < 12; i++)
            {
                ct.StepForward();
            }
            Assert.AreEqual(cr.NormalCalls, 2);
            Assert.AreEqual(cr.StepFunctionCall, 10);
            Assert.AreEqual(result, cr.RealResult);
        }
        public void ItShouldBePossibleToInvokeActionAsTask()
        {
            var ct = new CoroutineTestThread();
            var cr = new LocalInvokerCoroutine();

            cr.ActionAsTask = true;
            ct.Initialize();
            ct.AddCoroutine(cr);
            ct.StepForward();

            for (int i = 0; i < 12; i++)
            {
                ct.StepForward();
                Thread.Sleep(20);
            }
            Assert.IsTrue(cr.NormalCalls == 2 || cr.NormalCalls == 1);
            Assert.AreEqual(cr.StepFunctionCall, 1);
            Assert.AreEqual("ActionAsTask", cr.RealResult);
        }