Exemple #1
0
        public void DeserializeLinkToActivity()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"task1\"><activity>activity1</activity></task>");

            Assert.AreEqual("activity1", task.RelatedActivities[0], "related activity");
            Assert.AreEqual(1, task.RelatedActivities.Count, "related activities count");
        }
Exemple #2
0
        public void Serialize()
        {
            Task    task = new Task("task1");
            XmlNode xml  = TaskSerializer.Serialize(task);

            Assert.IsTrue(xml.OuterXml.Contains("task1"));
        }
Exemple #3
0
        public void SerializeWorkingProperty()
        {
            Task task = new Task("rest", false);

            XmlNode xml = TaskSerializer.Serialize(task);

            Assert.AreEqual("false", xml.Attributes["working"].Value);
        }
Exemple #4
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);
        }
Exemple #5
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"));
        }
        public void Deserialize()
        {
            XmlDocument doc = new XmlDocument();

            doc.AppendChild(doc.CreateElement("tasks")).InnerXml =
                TaskSerializer.Serialize(new Task("task1")).OuterXml;

            ITaskCollection taskCollection = TaskCollectionSerializer.Deserialize(doc);

            Assert.IsTrue(taskCollection.Contains("task1"));
        }
        public static XmlNode Serialize(ITaskCollection taskCollection)
        {
            XmlDocument doc  = new XmlDocument();
            XmlNode     root = doc.AppendChild(doc.CreateElement(ROOT_NODE));

            if (taskCollection != null)
            {
                foreach (Task task in taskCollection)
                {
                    root.InnerXml += TaskSerializer.Serialize(task).OuterXml;
                }
            }
            else
            {
                Log.Error("Could not serialize null tasks collection");
            }
            return(doc);
        }
        public static ITaskCollection Deserialize(XmlNode xml)
        {
            ITaskCollection taskCollection = new TaskCollection();

            foreach (XmlNode root in xml.ChildNodes)
            {
                if (root.Name == ROOT_NODE)
                {
                    foreach (XmlNode taskXml in root.ChildNodes)
                    {
                        Task task = TaskSerializer.Deserialize(taskXml);
                        if (task != null)
                        {
                            taskCollection.Add(task);
                        }
                    }
                }
            }
            return(taskCollection);
        }
Exemple #9
0
 public void DeserializeBrokenTask()
 {
     Assert.IsNull(TaskSerializer.Deserialize("<task>&</task>"));
 }
Exemple #10
0
        public void DeserializeWorkingProperty()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"task1\" working=\"false\"/>");

            Assert.IsFalse(task.IsWorking);
        }
Exemple #11
0
        public void Deserialize()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"deserialized_task\"></task>");

            Assert.AreEqual("deserialized_task", task.Name);
        }
Exemple #12
0
 public void SerializeWithNull()
 {
     Assert.IsNull(TaskSerializer.Serialize(null));
 }
Exemple #13
0
        public void DeserializeSubtask()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"parent\"><task name=\"sub\"/></task>");

            Assert.AreEqual("sub", task.Nodes[0].Name);
        }
Exemple #14
0
        public void DeserializeTaskWithIncorrectWorking()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"task1\" working=\"aaa\" />");

            Assert.IsTrue(task.IsWorking);
        }