コード例 #1
0
 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());
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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]");
 }
コード例 #4
0
        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"));
        }
コード例 #5
0
 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");
 }
コード例 #6
0
ファイル: TaskTest.cs プロジェクト: gayancc/lazycure-code
        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));
        }
コード例 #7
0
 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;
 }
コード例 #8
0
        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;
        }
コード例 #9
0
 public void IsWorkingNodeFalse()
 {
     Task task = new Task("original", false);
     Assert.IsFalse(tasks.IsWorkingNode(task));
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 public void UpdateIsWorkingProperty()
 {
     Task task = new Task("tested");
     tasks.Add(task);
     tasks.UpdateIsWorkingProperty("tested",false);
     Assert.IsFalse(task.IsWorking);
 }
コード例 #12
0
 public void UpdateIsWorking()
 {
     Task task = new Task("original", false);
     tasks.UpdateIsWorking(task, true);
     Assert.IsTrue(task.IsWorking);
 }
コード例 #13
0
 public void SubTaskHasTheSameWorkingProperty()
 {
     Task parent = new Task("parent",false);
     Task newTask = tasks.AddSubtask(parent);
     Assert.IsFalse(newTask.IsWorking);
 }
コード例 #14
0
 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);
 }
コード例 #15
0
ファイル: TaskTest.cs プロジェクト: gayancc/lazycure-code
 public void SetUp()
 {
     task = new Task("task1");
 }
コード例 #16
0
        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"));
        }
コード例 #17
0
 public void Serialize()
 {
     Task task = new Task("task1");
     XmlNode xml = TaskSerializer.Serialize(task);
     Assert.IsTrue(xml.OuterXml.Contains("task1"));
 }
コード例 #18
0
ファイル: TaskTest.cs プロジェクト: gayancc/lazycure-code
 public void TwoEqualTasks()
 {
     task = new Task("task1");
     Task task2 = new Task("task1");
     Assert.AreEqual(task, task2);
 }
コード例 #19
0
 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"));
 }
コード例 #20
0
 public void GetTaskReturnsExistentTask()
 {
     Task task1 = new Task("task1");
     tasks.Add(task1);
     Assert.AreSame(task1,tasks.GetTask("task1"));
 }
コード例 #21
0
        public void GetRelatedTask()
        {
            Task task = new Task("task1");
            task.RelatedActivities.Add("activity1");
            tasks.Add(task);

            string taskName = tasks.GetRelatedTaskName("activity1");

            Assert.AreEqual("task1", taskName);
        }
コード例 #22
0
 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"));
 }
コード例 #23
0
 public void IsWorkingNodeTrue()
 {
     Task task = new Task("original",true);
     Assert.IsTrue(tasks.IsWorkingNode(task));
 }
コード例 #24
0
 public void IsWorkingTaskFalse()
 {
     Task task = new Task("resting task",false);
     tasks.Add(task);
     Assert.IsFalse(tasks.IsWorking("resting task"));
 }
コード例 #25
0
        public void SerializeWorkingProperty()
        {
            Task task = new Task("rest", false);

            XmlNode xml = TaskSerializer.Serialize(task);

            Assert.AreEqual("false", xml.Attributes["working"].Value);
        }