public void HasBeenCancelledBy() { var agentId = new AgentId(1, 1); _task.Assigned = agentId; Assert.IsFalse(_task.IsCancelledBy(agentId)); _task.Cancel(); Assert.IsTrue(_task.IsCancelledBy(agentId)); }
/// <summary> /// CancelBlocker a task : /// remove a task from either To do or in progress /// </summary> /// <param name="task"></param> public void Cancel(SymuTask task) { if (task == null) { throw new ArgumentNullException(nameof(task)); } if (!task.IsAssigned) { return; } var todo = ToDo.Contains(task); var inProgress = InProgress.Contains(task); if (todo) { ToDo.Remove(task); } else if (inProgress) { InProgress.Remove(task); } else { return; } task.Cancel(); if (_debug) { Cancelled.Add(task); } // We don't want to track message as Task if (task.Parent is Message) { return; } if (todo) { TaskResult.ToDo--; } else { TaskResult.InProgress--; } TaskResult.Cancelled++; }