public void TestAfterElement() { var element1 = new HElement("h1"); var element2 = new HElement("h2"); var container = new HElement("div", element1, element2).AddClass("container"); element1.After(new HElement("p")); Assert.Equal(new String[] { "h1", "p", "h2" }, container.Elements().Select(e => e.Name)); var ex = Assert.Throws <InvalidOperationException>(() => container.After(new HElement("p"))); Assert.Equal("No parent found.", ex.Message); }