コード例 #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");
        }
コード例 #2
0
        public void Serialize()
        {
            Task    task = new Task("task1");
            XmlNode xml  = TaskSerializer.Serialize(task);

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

            XmlNode xml = TaskSerializer.Serialize(task);

            Assert.AreEqual("false", xml.Attributes["working"].Value);
        }
コード例 #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);
        }
コード例 #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"));
        }
コード例 #6
0
        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"));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 public void DeserializeBrokenTask()
 {
     Assert.IsNull(TaskSerializer.Deserialize("<task>&</task>"));
 }
コード例 #10
0
        public void DeserializeWorkingProperty()
        {
            Task task = TaskSerializer.Deserialize("<task name=\"task1\" working=\"false\"/>");

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

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

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

            Assert.IsTrue(task.IsWorking);
        }