public IEnumerator TestContinuatorSimple() { yield return(null); //careful, runners can be garbage collected if they are not referenced somewhere and the //framework does not keep a reference using (var updateMonoRunner = new UpdateMonoRunner("update")) { var cont = new Enumerator(1).RunOnScheduler(updateMonoRunner); Assert.That((cont as IEnumerator).MoveNext(), Is.True); updateMonoRunner.Step(); Assert.That((cont as IEnumerator).MoveNext(), Is.True); updateMonoRunner.Step(); Assert.That((cont as IEnumerator).MoveNext(), Is.False); } }
public IEnumerator TestParallelWithMixedYield() { yield return(null); using (var runner = new UpdateMonoRunner("test2")) { var enumerator = new Enumerator(1); _parallelTasks1.Add(enumerator); var enumerator1 = new Enumerator(2); _parallelTasks1.Add(enumerator1); var enumerator2 = new Enumerator(3); _parallelTasks1.Add(enumerator2); var enumerator3 = new Enumerator(4); _parallelTasks1.Add(enumerator3); var enumerator4 = new Enumerator(5); _parallelTasks1.Add(enumerator4); var enumerator5 = new Enumerator(6); _parallelTasks1.Add(enumerator5); _parallelTasks1.RunOnScheduler(runner); Assert.IsFalse(enumerator.AllRight); Assert.IsFalse(enumerator1.AllRight); Assert.IsFalse(enumerator2.AllRight); Assert.IsFalse(enumerator3.AllRight); Assert.IsFalse(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsFalse(enumerator1.AllRight); Assert.IsFalse(enumerator2.AllRight); Assert.IsFalse(enumerator3.AllRight); Assert.IsFalse(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsTrue(enumerator1.AllRight); Assert.IsFalse(enumerator2.AllRight); Assert.IsFalse(enumerator3.AllRight); Assert.IsFalse(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsTrue(enumerator1.AllRight); Assert.IsTrue(enumerator2.AllRight); Assert.IsFalse(enumerator3.AllRight); Assert.IsFalse(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsTrue(enumerator1.AllRight); Assert.IsTrue(enumerator2.AllRight); Assert.IsTrue(enumerator3.AllRight); Assert.IsFalse(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsTrue(enumerator1.AllRight); Assert.IsTrue(enumerator2.AllRight); Assert.IsTrue(enumerator3.AllRight); Assert.IsTrue(enumerator4.AllRight); Assert.IsFalse(enumerator5.AllRight); runner.Step(); Assert.IsTrue(enumerator.AllRight); Assert.IsTrue(enumerator1.AllRight); Assert.IsTrue(enumerator2.AllRight); Assert.IsTrue(enumerator3.AllRight); Assert.IsTrue(enumerator4.AllRight); Assert.IsTrue(enumerator5.AllRight); } }