Exemplo n.º 1
0
        public void TestReplace_TagById(string source, string expected)
        {
            var replacer = new HtmlDocumentReplacer();
            var context  = new DataContext();

            replacer.ReplaceTagIds.Add(new ReplaceParameter("a1", "1{0:D6}"));

            context.StartFrom = 10;

            source = replacer.Replace(source, context);
            Assert.Equal(expected, source);
        }
Exemplo n.º 2
0
        public void TestReplace_TagByDictionary()
        {
            var replacer = new HtmlDocumentReplacer();
            var context  = new DataContext();

            context.DataDictionary.AddValue("台北市", "dictionary");

            replacer.ReplaceTagIds.Add(new ReplaceParameter("a1", "ignore"));

            var source   = "<p id=\"a1\">&#21488;&#21271;&#24066;</p>";
            var expected = "<p id=\"a1\">dictionary</p>";

            source = replacer.Replace(source, context);
            Assert.Equal(expected, source);
        }