public void ZTaskManager_SelectTasks(TaskFlag flag, IEnumerable <ITask> expectedResult) { // Arrange foreach (var task in tasks) { manager.PushTask(task); } foreach (var task in pTasks) { manager.PushTaskWithPriority(task); } manager.Update(); // Assert Assert.That(manager.SelectTasks(flag), Is.EquivalentTo(expectedResult)); }
public void View_SelectedTasks(string[] commands) { // Arrange bool detail = false; TaskFlag selection = TaskFlag.None; // Collect selection flags for (int i = 1; i < commands.Length; ++i) { switch (commands[i]) { case PrioritizedTaskFlag: selection = selection | TaskFlag.Prioritized; break; case NonPrioritizedTaskFlag: selection = selection | TaskFlag.NonPrioritized; break; case UrgentTaskFlag: selection = selection | TaskFlag.Urgent; break; case DangerTaskFlag: selection = selection | TaskFlag.Danger; break; case ScheduledTaskFlag: selection = selection | TaskFlag.Scheduled; break; case NonScheduledTaskFlag: selection = selection | TaskFlag.NonScheduled; break; case ShowDetail: detail = true; break; default: throw new Exception("Bad selection command"); } } // Select tasks and Print var selectedTasks = manager.SelectTasks(selection); if (selectedTasks.Any()) { if (detail) { Print(FormatUtil.BreakLine); ConsoleUtil.WriteTasksInDetail(selectedTasks); detail = false; } else { for (int i = 0; i < selectedTasks.Count; ++i) { Print($"{i}. {selectedTasks[i].Title}"); } } } }
/// <summary> /// Removes a flag from the task /// </summary> /// <param name="flag">The flag</param> public void RemoveFlag(TaskFlag flag) { m_flags &= ~flag; }
/// <summary> /// Adds a flag to the task /// </summary> /// <param name="flag">The flag</param> public void AddFlag(TaskFlag flag) { m_flags |= flag; }
/// <summary> /// Checks if the task has a flag /// </summary> /// <param name="flag">The flag</param> /// <returns>If it has the flag</returns> public bool HasFlag(TaskFlag flag) { return((m_flags & flag) == flag); }
public TaskItem(TaskFlag flag, Playground hive = null, PlaygroundHost host = null, string depotKey = null, string appId = null) { this.Flag = flag; this.Hive = hive; this.Host = host; this.DepotKey = depotKey; this.AppId = appId; }
Gdk.Pixbuf GetSmallFlag(TaskFlag flag) { if (!m_small_flags.ContainsKey (flag)) { var pixbuf = GetFlag (flag); m_small_flags [flag] = pixbuf.ScaleSimple (12, 12, Gdk.InterpType.Bilinear); } return m_small_flags [flag]; }
Gdk.Pixbuf GetFlag(TaskFlag flag) { if (!m_flags.ContainsKey (flag)) { var flag_name = flag.ToString ().ToLower (); var pixbuf = new Gdk.Pixbuf (Assembly.GetExecutingAssembly (), "Resources.flag-" + flag_name + ".png"); m_flags [flag] = pixbuf; } return m_flags [flag]; }
/// <summary> /// <see cref="TaskFlag.Prioritized"/> or <see cref="TaskFlag.NonPrioritized"/> is /// a must. Based on which the user may add additional constraints such as /// whether the task is scheduled or not, or if the task is urgent or not. /// </summary> /// <param name="flag"></param> /// <returns></returns> public List <ITask> SelectTasks(TaskFlag flag) { var from = new List <ITask>(); if ((flag & TaskFlag.Prioritized) == TaskFlag.Prioritized) { if (CurrentTaskIsPrioritized) { from.Add(CurrentTask); } from.AddRange(priorityList.PeekAll()); } if ((flag & TaskFlag.NonPrioritized) == TaskFlag.NonPrioritized) { if (!CurrentTaskIsPrioritized) { from.Add(CurrentTask); } from.AddRange(taskStack.PeekAll()); } List <Func <ITask, bool> > selectFunc = new List <Func <ITask, bool> >(); if ((flag & TaskFlag.Scheduled) == TaskFlag.Scheduled) { selectFunc.Add(task => task is ZScheduledTask); } if ((flag & TaskFlag.NonScheduled) == TaskFlag.NonScheduled) { selectFunc.Add(task => !(task is ZScheduledTask)); } if ((flag & TaskFlag.Urgent) == TaskFlag.Urgent) { selectFunc.Add(task => { var scheduled = task as ZScheduledTask; return(scheduled != null && scheduled.IsUrgent()); }); } if ((flag & TaskFlag.Danger) == TaskFlag.Danger) { selectFunc.Add(task => { var scheduled = task as ZScheduledTask; return(scheduled != null && scheduled.IsInDanger()); }); } if (selectFunc.Any()) { return(from.Where(task => { foreach (Func <ITask, bool> func in selectFunc) { if (!func(task)) { return false; } } return true; }).ToList()); } else { return(from); } }