Пример #1
0
        public void AddAfterSelf_NullObjectInContent_ThrowsArgumentNullException()
        {
            HtmlElement element = new HtmlElement("element");

            Assert.Throws <ArgumentNullException>("content", () => element.AddAfterSelf(new HtmlElement[] { null }));
            Assert.Throws <ArgumentNullException>("content", () => element.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[] { null }));
        }
Пример #2
0
        public void AddAfterSelf_SameElement_ThrowsInvalidOperationException()
        {
            HtmlElement element = new HtmlElement("html");

            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf(element));
            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf(new HtmlElement[] { element }));
            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[] { element }));
        }
Пример #3
0
        public void AddAfterSelf_ElementToVoidElement_ThrowsInvalidOperationException()
        {
            HtmlElement element    = new HtmlElement("br", isVoid: true);
            HtmlElement newElement = new HtmlElement("p");

            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf(newElement));
            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf(new HtmlElement[] { newElement }));
            Assert.Throws <InvalidOperationException>(() => element.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[] { newElement }));
        }
Пример #4
0
        public void AddAfterSelf_DuplicateElement_ThrowsInvalidOperationException()
        {
            HtmlElement parent  = new HtmlElement("parent");
            HtmlElement element = new HtmlElement("child");

            parent.Add(element);

            Assert.Throws <InvalidOperationException>(() => parent.AddAfterSelf(element));
            Assert.Throws <InvalidOperationException>(() => parent.AddAfterSelf(new HtmlElement[] { element }));
            Assert.Throws <InvalidOperationException>(() => parent.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[] { element }));
        }
Пример #5
0
        public void AddAfterSelf_IEnumerableHtmlObject_Empty()
        {
            HtmlElement parent  = new HtmlElement("html");
            HtmlElement element = new HtmlElement("body");

            element.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[0]);
            Assert.Empty(parent.Elements());
            Assert.Empty(parent.Attributes());
        }
Пример #6
0
        public void AddAfterSelf_ParamsHtmlObject_Empty()
        {
            HtmlElement parent  = new HtmlElement("html");
            HtmlElement element = new HtmlElement("body");

            element.AddAfterSelf(new HtmlElement[0]);
            Assert.Empty(parent.Elements());
            Assert.Empty(parent.Attributes());
        }
Пример #7
0
        public void AddAfterSelf_HtmlNode()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlElement child1 = new HtmlElement("child1");

            parent.Add(child1);

            // Element
            HtmlElement child2 = new HtmlElement("child2");

            child1.AddAfterSelf(child2);
            Assert.Equal(parent, child2.Parent);
            Assert.Equal(new HtmlElement[] { child1, child2 }, parent.Elements());

            // Comment
            HtmlComment comment = new HtmlComment("comment");

            child1.AddAfterSelf(comment);
            Assert.Equal(parent, comment.Parent);
            Assert.Equal(new HtmlObject[] { child1, comment, child2 }, parent.Nodes());
        }
Пример #8
0
        public void AddAfterSelf_IEnumerableHtmlObject()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlElement child1 = new HtmlElement("child1");

            parent.Add(child1);

            HtmlElement child2 = new HtmlElement("child2");
            HtmlElement child3 = new HtmlElement("child3");

            child1.AddAfterSelf((IEnumerable <HtmlElement>) new HtmlElement[] { child2, child3 });

            Assert.Equal(parent, child2.Parent);
            Assert.Equal(parent, child3.Parent);
            Assert.Equal(new HtmlElement[] { child1, child2, child3 }, parent.Elements());
        }