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)); }
public void ZTaskStack_PushAndPop() { // Arrange int[] pushSequence = { 1, 7, 0, 2, 4, 3, 5, 6 }; int[] popSequence = pushSequence.Reverse().ToArray(); ZTaskStack testStack = new ZTaskStack(); // Assume Assume.That(tasks.Count, Is.GreaterThanOrEqualTo(8)); Assume.That(testStack.Empty(), Is.True); // Act foreach (int i in pushSequence) { testStack.Push(tasks[i]); } // Assert foreach (int i in popSequence) { Assert.That(testStack.Pop(), Is.EqualTo(tasks[i])); } }