Example #1
0
                /// <summary>
                /// Tests the ElementsAfterSelf methods on Node.
                /// </summary>
                /// <param name="context"></param>
                /// <returns></returns>
                //[Variation(Desc = "NodeElementsAfterSelf")]
                public void NodeElementsAfterSelf()
                {
                    XElement parent = new XElement("parent");

                    XElement child1a = new XElement("child1", new XElement("nested"));
                    XElement child1b = new XElement("child1", new XElement("nested"));
                    XElement child2a = new XElement("child2", new XElement("nested"));
                    XElement child2b = new XElement("child2", new XElement("nested"));

                    XComment comment = new XComment("this is a comment");

                    // If no parent, should not be any elements before it.
                    Validate.Enumerator(comment.ElementsAfterSelf(), new XElement[0]);

                    parent.Add(child1a);
                    parent.Add(comment);
                    parent.Add(child1b);
                    parent.Add(child2a);
                    parent.Add(child2b);

                    Validate.Enumerator(
                        comment.ElementsAfterSelf(),
                        new XElement[] { child1b, child2a, child2b });

                    Validate.Enumerator(
                        comment.ElementsAfterSelf("child1"),
                        new XElement[] { child1b });

                    Validate.Enumerator(
                        child1a.ElementsAfterSelf("child1"),
                        new XElement[] { child1b });

                    Validate.Enumerator(child2b.ElementsAfterSelf(), new XElement[0]);
                }
Example #2
0
        public void NodeElementsAfterSelf()
        {
            XElement parent = new XElement("parent");

            XElement child1a = new XElement("child1", new XElement("nested"));
            XElement child1b = new XElement("child1", new XElement("nested"));
            XElement child2a = new XElement("child2", new XElement("nested"));
            XElement child2b = new XElement("child2", new XElement("nested"));

            XComment comment = new XComment("this is a comment");

            // If no parent, should not be any elements before it.
            Assert.Empty(comment.ElementsAfterSelf());

            parent.Add(child1a);
            parent.Add(comment);
            parent.Add(child1b);
            parent.Add(child2a);
            parent.Add(child2b);

            Assert.Equal(new XElement[] { child1b, child2a, child2b }, comment.ElementsAfterSelf());

            Assert.Equal(new XElement[] { child1b }, comment.ElementsAfterSelf("child1"));

            Assert.Equal(new XElement[] { child1b }, child1a.ElementsAfterSelf("child1"));

            Assert.Empty(child2b.ElementsAfterSelf());
        }