Ejemplo n.º 1
0
        protected void AddChild(XNode parent, TestItem node)
        {
            //<TestModule/TestCase/Variation>
            string name = node.Type.ToString();

            //Create the Element
            CXmlElement element = (CXmlElement) new XElement(name);

            if (parent is XDocument)
            {
                ((XDocument)parent).Add(element);
            }
            else if (parent is XElement)
            {
                ((XElement)parent).Add(element);
            }
            else
            {
                throw new Exception("Error in Add Child");
            }

            //Add typed properties
            AddProperty(element, "Name", node.Name, 0);
            AddProperty(element, "Desc", node.Desc, 0);
            AddProperty(element, "Id", node.Order, 0);
            AddProperty(element, "Priority", node.Priority, 0);
            AddProperty(element, "Owner", node.Owner, 0);
            AddProperty(element, "Owners", node.Owners, TestPropertyFlags.MultipleValues);
            AddProperty(element, "Version", node.Version, 0);

            //Add extended properties
            AddProperties(element, node);

            //Add our own uniqueid (for fast assoication later)
            //Note: We place this 'userdata' into our own version of the XmlElement, (derived class)
            element.UserData = ++pnextuniqueid;
            puniqueids.Add(pnextuniqueid, node);

            //Recursure through the children
            foreach (TestItem childnode in node.Children)
            {
                this.AddChild(element, childnode);
            }
        }
Ejemplo n.º 2
0
        protected TestItem FindMatchingNode(XElement xmlnode)
        {
            TestItem found = null;

            //Matching nodes are always elements (testmodule, testcase, variation)
            while (xmlnode.NodeType != XmlNodeType.Element)
            {
                xmlnode = xmlnode.Parent;
            }

            //Note: We actually placed a uniqueid in the XmlElement node itself (derived node type)
            CXmlElement element = xmlnode as CXmlElement;

            if (element != null)
            {
                found = (TestItem)puniqueids[element.UserData];
            }

            return(found);
        }