示例#1
0
        public void TestWrapElement()
        {
            var n1 = new HElement("span", "Content");
            var n2 = new HElement("div", n1);

            Assert.Same(n1, n1.Wrap(new HElement("strong", new HElement("em"))));
            Assert.Equal("<div><strong><em><span>Content</span></em></strong></div>", n2.ToString());

            n1 = null;
            Assert.Null(n1.Wrap(new HElement("strong", new HElement("em"))));
            Assert.Equal("<div><strong><em><span>Content</span></em></strong></div>", n2.ToString());
        }
示例#2
0
        public void TestWrapElementsByCallback()
        {
            var n1 = new HElement("span", "Content 1");
            var n2 = new HElement("span", "Content 2");
            var n3 = new HElement("div", n1, n2);

            Assert.Equal("<div><span>Content 1</span><span>Content 2</span></div>", n3.ToString());

            var elements = new HElement[] { n1, n2 };

            Assert.Same(elements, elements.Wrap((e, i) => new HElement("strong", "C" + i.ToString(), new HElement("em"))));
            Assert.Equal("<div><strong>C0<em><span>Content 1</span></em></strong><strong>C1<em><span>Content 2</span></em></strong></div>", n3.ToString());

            elements = null;
            Assert.Null(elements.Wrap((e, i) => new HElement("strong", "C" + i.ToString(), new HElement("em"))));
            Assert.Equal("<div><strong>C0<em><span>Content 1</span></em></strong><strong>C1<em><span>Content 2</span></em></strong></div>", n3.ToString());
        }
示例#3
0
        public void TestWrapElements()
        {
            var n1 = new HElement("span", "Content 1");
            var n2 = new HElement("span", "Content 2");
            var n3 = new HElement("div", n1, n2);

            Assert.Equal("<div><span>Content 1</span><span>Content 2</span></div>", n3.ToString());

            IEnumerable <HElement> elements = new HElement[] { n1, n2 };

            Assert.Same(elements, elements.Wrap(new HElement("strong", new HElement("em"))));
            Assert.Equal("<div><strong><em><span>Content 1</span></em></strong><strong><em><span>Content 2</span></em></strong></div>", n3.ToString());

            elements = null;
            Assert.Null(elements.Wrap(new HElement("strong", new HElement("em"))));
            Assert.Equal("<div><strong><em><span>Content 1</span></em></strong><strong><em><span>Content 2</span></em></strong></div>", n3.ToString());
        }