public void GetAllSubTaskNames() { Task parent = new Task("parent"); tasks.Add(parent); Task subtask = tasks.AddSubtask(parent); subtask.Name = "subtask"; Assert.AreEqual(new string[] { "parent", "subtask" }, tasks.GetAllTasksNames()); }
public void AddSiblingSetIsWorkingFromParent() { Task parent = new Task("parent", false); Task previous = new Task("previous"); parent.Nodes.Add(previous); TreeNode newNode = tasks.AddTaskAfter(previous); Task task = newNode as Task; Assert.IsFalse(task.IsWorking); }
public void AddTaskAfter() { Task previous = new Task("previous"); tasks.Add(previous); TreeNode node = tasks.AddTaskAfter(previous); Task task = node as Task; Assert.AreEqual(2, tasks.Count, "Count"); Assert.AreEqual(task, tasks[1], "Task[1]"); }
public void SerializeLinkToActivityWithSpecialSymbols() { Task task = new Task("task1"); task.RelatedActivities.Add("a&b>c"); XmlNode xml = TaskSerializer.Serialize(task); Assert.IsTrue(xml.InnerText.Contains("a&b>c")); }
public void AddTaskAfterSubtask() { Task root = new Task("root"); Task sub = new Task("sub"); root.Nodes.Add(sub); tasks.Add(root); TreeNode node = tasks.AddTaskAfter(sub); Task task = node as Task; Assert.AreEqual(1, tasks.Count, "Count on root level"); Assert.AreEqual(2, tasks[0].Nodes.Count, "Count of subnodes"); Assert.AreEqual(node, tasks[0].Nodes[1], "new node"); }
public void TasksShouldNotBeEqualEvenIfTheirHashCodesAre() { string name1 = "699391"; string name2 = "1241308"; // just to make sure that hash codes are equal Assert.IsTrue(name1.GetHashCode() == name2.GetHashCode()); task = new Task(name1); Task task2 = new Task(name2); Assert.IsFalse(task.Equals(task2)); Assert.IsFalse(task2.Equals(task)); }
public static XmlNode Serialize(Task task) { if (task != null) { XmlNode xml = doc.CreateElement(TASK_ELEMENT); xml.Attributes.Append(doc.CreateAttribute(NAME_ATTRIBUTE)).Value = task.Name; xml.Attributes.Append(doc.CreateAttribute(WORKING_ATTRIBUTE)).Value = Utilities.BoolToString(task.IsWorking); foreach (string activity in task.RelatedActivities) { xml.AppendChild(doc.CreateElement(ACTIVITY_ELEMENT)).InnerText = activity; } foreach (Task subtask in task.Nodes) xml.AppendChild(Serialize(subtask)); return xml; } else return null; }
public static Task Deserialize(XmlNode xml) { if (xml != null) { string name = null; bool isWorking = true; foreach (XmlAttribute attribute in xml.Attributes) switch (attribute.Name) { case NAME_ATTRIBUTE: name = attribute.Value; break; case WORKING_ATTRIBUTE: isWorking = Utilities.StringToBool(attribute.Value); break; } if (name != null) { Task task = new Task(name, isWorking); foreach (XmlNode node in xml.ChildNodes) { switch (node.Name) { case TASK_ELEMENT: task.Nodes.Add(Deserialize(node)); break; case ACTIVITY_ELEMENT: if (node.InnerText != string.Empty) task.RelatedActivities.Add(node.InnerText); break; default: Log.Error("'{0}' is unsupported element name. Supported elements are: {1},{2}", node.Name, TASK_ELEMENT, ACTIVITY_ELEMENT); break; } } return task; } } return null; }
public void IsWorkingNodeFalse() { Task task = new Task("original", false); Assert.IsFalse(tasks.IsWorkingNode(task)); }
public void SerializeSubtask() { Task task = new Task("parent"); task.Nodes.Add(new Task("sub")); XmlNode xml = TaskSerializer.Serialize(task); Assert.AreEqual("sub", xml.ChildNodes[0].Attributes["name"].Value); }
public void UpdateIsWorkingProperty() { Task task = new Task("tested"); tasks.Add(task); tasks.UpdateIsWorkingProperty("tested",false); Assert.IsFalse(task.IsWorking); }
public void UpdateIsWorking() { Task task = new Task("original", false); tasks.UpdateIsWorking(task, true); Assert.IsTrue(task.IsWorking); }
public void SubTaskHasTheSameWorkingProperty() { Task parent = new Task("parent",false); Task newTask = tasks.AddSubtask(parent); Assert.IsFalse(newTask.IsWorking); }
public void Rename() { Task task = new Task("original"); tasks.Rename(task, "new name"); Assert.AreEqual("new name", task.Name); Assert.AreEqual("new name", task.Text); }
public void SetUp() { task = new Task("task1"); }
public void LinkActivityAndTask() { Task task = new Task("linked task"); tasks.Add(task); bool isLinked = tasks.LinkActivityAndTask("activity1", "linked task"); Assert.IsTrue(isLinked); Assert.IsTrue(task.RelatedActivities.Contains("activity1")); }
public void Serialize() { Task task = new Task("task1"); XmlNode xml = TaskSerializer.Serialize(task); Assert.IsTrue(xml.OuterXml.Contains("task1")); }
public void TwoEqualTasks() { task = new Task("task1"); Task task2 = new Task("task1"); Assert.AreEqual(task, task2); }
public void GetTaskSearchInSubNodes() { Task root = new Task("root"); Task sub = new Task("sub"); root.Nodes.Add(sub); tasks.Add(root); Assert.AreEqual(sub, tasks.GetTask("sub")); }
public void GetTaskReturnsExistentTask() { Task task1 = new Task("task1"); tasks.Add(task1); Assert.AreSame(task1,tasks.GetTask("task1")); }
public void GetRelatedTask() { Task task = new Task("task1"); task.RelatedActivities.Add("activity1"); tasks.Add(task); string taskName = tasks.GetRelatedTaskName("activity1"); Assert.AreEqual("task1", taskName); }
public void GetRelatedSubtask() { Task root = new Task("root"); Task subTask = new Task("sub"); subTask.RelatedActivities.Add("activity1"); root.Nodes.Add(subTask); tasks.Add(root); Assert.AreEqual("sub", tasks.GetRelatedTaskName("activity1")); }
public void IsWorkingNodeTrue() { Task task = new Task("original",true); Assert.IsTrue(tasks.IsWorkingNode(task)); }
public void IsWorkingTaskFalse() { Task task = new Task("resting task",false); tasks.Add(task); Assert.IsFalse(tasks.IsWorking("resting task")); }
public void SerializeWorkingProperty() { Task task = new Task("rest", false); XmlNode xml = TaskSerializer.Serialize(task); Assert.AreEqual("false", xml.Attributes["working"].Value); }