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"); }
public void Serialize() { Task task = new Task("task1"); XmlNode xml = TaskSerializer.Serialize(task); Assert.IsTrue(xml.OuterXml.Contains("task1")); }
public void SerializeWorkingProperty() { Task task = new Task("rest", false); XmlNode xml = TaskSerializer.Serialize(task); Assert.AreEqual("false", xml.Attributes["working"].Value); }
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 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); }
public void DeserializeBrokenTask() { Assert.IsNull(TaskSerializer.Deserialize("<task>&</task>")); }
public void DeserializeWorkingProperty() { Task task = TaskSerializer.Deserialize("<task name=\"task1\" working=\"false\"/>"); Assert.IsFalse(task.IsWorking); }
public void Deserialize() { Task task = TaskSerializer.Deserialize("<task name=\"deserialized_task\"></task>"); Assert.AreEqual("deserialized_task", task.Name); }
public void SerializeWithNull() { Assert.IsNull(TaskSerializer.Serialize(null)); }
public void DeserializeSubtask() { Task task = TaskSerializer.Deserialize("<task name=\"parent\"><task name=\"sub\"/></task>"); Assert.AreEqual("sub", task.Nodes[0].Name); }
public void DeserializeTaskWithIncorrectWorking() { Task task = TaskSerializer.Deserialize("<task name=\"task1\" working=\"aaa\" />"); Assert.IsTrue(task.IsWorking); }