public void ZTaskStack_PullDangerTasks() { // Arrange ZTaskStack testStack = new ZTaskStack(); testStack.PushAll(tasks); IEnumerable <ITask> dangers = tasks.Where(t => { ZScheduledTask st = t as ZScheduledTask; if (st != null && st.IsInDanger()) { return(true); } return(false); }); int numOfDangers = dangers.Count(); // Assume Assume.That(testStack.PeekAll(), Is.EquivalentTo(tasks)); // Act testStack.PullDangerTasks(); // Assert var actual = testStack.PeekTasks(numOfDangers); Assert.That(actual, Is.EquivalentTo(dangers)); }
public void ZTaskStack_DelayTaskToBottom() { // Arrange ZTaskStack testStack = new ZTaskStack(); testStack.PushAll(tasks); // Assume Assume.That(testStack.PeekAll(), Is.EquivalentTo(tasks)); // Act var curTask = testStack.Peek(); testStack.DelayCurrentTaskToBottom(); // Assert int lim = testStack.Count() - 1; for (int i = 0; i < lim; ++i) { testStack.Pop(); } Assert.That(testStack.Peek(), Is.EqualTo(curTask)); testStack.Pop(); Assert.That(testStack.Empty(), Is.True); }
public void ZTaskStack_DelayTaskBy(int i) { // Arrange ZTaskStack testStack = new ZTaskStack(); testStack.PushAll(tasks); // Assume Assume.That(testStack.PeekAll(), Is.EquivalentTo(tasks)); Assume.That(i, Is.LessThan(tasks.Count)); // Act var curtask = testStack.Peek(); testStack.DelayCurrentTaskBy(i); // Assert for (int j = 0; j < i; ++j) { testStack.Pop(); } Assert.That(testStack.Peek(), Is.EqualTo(curtask)); }