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 })); }
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 })); }
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 })); }
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 })); }
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()); }
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()); }
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()); }
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()); }