示例#1
0
文件: SDMNode.cs 项目: johnhhm/corefx
                /// <summary>
                /// Tests the ContentBeforeSelf method on Node.
                /// </summary>
                /// <param name="context"></param>
                /// <returns></returns>
                //[Variation(Desc = "NodeContentBeforeSelf")]
                public void NodeContentBeforeSelf()
                {
                    XElement parent = new XElement("parent");

                    XComment child = new XComment("Self is a comment");

                    XComment comment1 = new XComment("Another comment");
                    XComment comment2 = new XComment("Yet another comment");
                    XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar"));
                    XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar"));
                    XAttribute attribute = new XAttribute("attribute", "value");

                    // If no parent, should not be any content before it.
                    Validate.Enumerator(child.NodesBeforeSelf(), new XNode[0]);

                    // Add some content, including the child, and validate.
                    parent.Add(attribute);
                    parent.Add(comment1);
                    parent.Add(element1);

                    parent.Add(child);

                    parent.Add(comment2);
                    parent.Add(element2);

                    Validate.Enumerator(
                        child.NodesBeforeSelf(),
                        new XNode[] { comment1, element1 });
                }
示例#2
0
文件: SDMNode.cs 项目: johnhhm/corefx
                /// <summary>
                /// Tests the AllContentBeforeSelf method on Node.
                /// </summary>
                /// <param name="context"></param>
                /// <returns></returns>
                //[Variation(Desc = "NodeAllContentBeforeSelf")]
                public void NodeAllContentBeforeSelf()
                {
                    XElement parent = new XElement("parent");

                    XComment child = new XComment("Self is a comment");

                    XComment comment1 = new XComment("Another comment");
                    XComment comment2 = new XComment("Yet another comment");
                    XElement element1 = new XElement("childelement", new XElement("nested"), new XAttribute("foo", "bar"));
                    XElement element2 = new XElement("childelement2", new XElement("nested"), new XAttribute("foo", "bar"));
                    XAttribute attribute = new XAttribute("attribute", "value");

                    // If no parent, should not be any content before it.
                    Validate.Enumerator<XNode>(child.NodesBeforeSelf(), new XNode[0]);

                    // Add child to parent. Should still be no content before it.
                    // Attributes are not content.
                    parent.Add(attribute);
                    parent.Add(child);
                    Validate.Enumerator<XNode>(child.NodesBeforeSelf(), new XNode[0]);

                    // Add more children and validate.
                    parent.Add(comment1);
                    parent.Add(element1);

                    Validate.Enumerator<XNode>(child.NodesBeforeSelf(), new XNode[0]);

                    parent.AddFirst(element2);
                    parent.AddFirst(comment2);

                    Validate.Enumerator<XNode>(child.NodesBeforeSelf(), new XNode[] { comment2, element2 });
                }