public void NestedEnumerableWithCoroutinesShoulBeConsideredWithException() { var ex = new Exception(); var subCoroutine = new CoroutineStackTestCoroutine(ex); var steps = new List <Step> { Step.DataStep(new EnumeratorWrapper { IsCoroutine = true, SubCoroutine = subCoroutine }) }; try { subCoroutine.Run().ToList(); } catch (Exception exx) { subCoroutine.OnError(exx); } var root = new CoroutineStackTestCoroutine(); var cst = new CoroutineStack(steps.GetEnumerator(), root); Assert.IsTrue(cst.MoveNext()); var current = cst.Current as Step; Assert.IsTrue(current.HasData); Assert.IsInstanceOfType(current.Data, typeof(EnumeratorWrapper)); var enumData = current.Data as EnumeratorWrapper; Assert.AreEqual(subCoroutine, enumData.SubCoroutine); Assert.IsTrue(cst.MoveNext()); Assert.IsFalse(cst.MoveNext()); }
public void NestedEnumerableWithCoroutinesWantingToTerminate() { var subCoroutine = new CoroutineStackTestCoroutine(true); var steps = new List <Step> { Step.DataStep(new EnumeratorWrapper { IsCoroutine = true, SubCoroutine = subCoroutine, }) }; var root = new CoroutineStackTestCoroutine(); var cst = new CoroutineStack(steps.GetEnumerator(), root); Assert.IsTrue(cst.MoveNext()); var current = cst.Current as Step; Assert.IsTrue(current.HasData); Assert.IsInstanceOfType(current.Data, typeof(EnumeratorWrapper)); var enumData = current.Data as EnumeratorWrapper; Assert.AreEqual(subCoroutine, enumData.SubCoroutine); subCoroutine.Run().ToList(); Assert.IsTrue(cst.MoveNext()); Assert.IsFalse(cst.MoveNext()); }
public void NestedEnumerableWithCoroutinesShoulBeConsidered() { var subCoroutine = new CoroutineStackTestCoroutine(); var steps = new List <Step> { Step.DataStep(new EnumeratorWrapper { IsCoroutine = true, SubCoroutine = subCoroutine, }) }; subCoroutine.Run().ToList(); var root = new CoroutineStackTestCoroutine(); var cst = new CoroutineStack(steps.GetEnumerator(), root); Assert.IsTrue(cst.MoveNext()); var current = cst.Current as Step; Assert.IsTrue(current.HasData); Assert.IsInstanceOfType(current.Data, typeof(EnumeratorWrapper)); var enumData = current.Data as EnumeratorWrapper; Assert.AreEqual(subCoroutine, enumData.SubCoroutine); Assert.IsTrue(cst.MoveNext()); //Normally invoked by the thread subCoroutine.ShouldTerminate = true; Assert.IsTrue(cst.MoveNext()); Assert.IsFalse(cst.MoveNext()); }