コード例 #1
0
ファイル: ElementTest.cs プロジェクト: ygrenier/HDocument
        public void TestReplaceAll()
        {
            var n1 = new HText("Content");
            var n2 = new HElement("span", n1);
            var n3 = new HElement("span", "Another content");
            var n4 = new HElement("div", n2, n3);

            var elements = new HElement[] { new HElement("p", "p 1"), null, new HElement("div", "div 2") };

            Assert.Same(elements, elements.ReplaceAll(n3, n2));
            Assert.Equal("<div><p>p 1</p><div>div 2</div><p>p 1</p><div>div 2</div></div>", n4.ToString());

            elements = null;
            Assert.Null(elements.ReplaceAll(n3, n2));
            Assert.Equal("<div><p>p 1</p><div>div 2</div><p>p 1</p><div>div 2</div></div>", n4.ToString());
        }