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