public void TaskStack_TwoTasksThenOne() { var taskStack = new MTaskStack(); var num = new MInt(5); var a = new MTask((t) => num.Value == 4); var b = new MTask((t) => num.Value == 3); var c = new MTask((t) => num.Value == 2); c.OnComplete += () => num.Value = 0; taskStack.PushQueue(a); taskStack.PushQueue(b); num.Value--; taskStack.Evaluate(); Assert.AreSame(b, taskStack.Current); num.Value--; taskStack.Evaluate(); taskStack.Evaluate(); taskStack.PushQueue(c); taskStack.Evaluate(); num.Value = 2; taskStack.Evaluate(); Assert.AreEqual(0, num.Value); Assert.AreEqual(0, taskStack.Count); }
public void TaskStack_SingleCompleted() { var taskStack = new MTaskStack(); var num = new MInt(5); var a = new MTask((t) => num.Value == 4); a.OnComplete += () => num.Value = 0; taskStack.PushQueue(a); num.Value--; taskStack.Evaluate(); Assert.That(num.Value == 0); Assert.AreEqual(0, taskStack.Count); }
protected override void Update() { base.Update(); _tasks.Evaluate(); }