Пример #1
0
        public void MixedAttributes()
        {
            string input = "<name attr1=\"value\" attr2 attr3=\'\'>";

            TextFormatter formatter = new TextFormatter(input);

            NormalTagParser parser = new NormalTagParser(formatter);

            if (parser.CanParse())
            {
                parser.Parse();
            }

            HtmlDocumentNode node = parser.ParsedNode;

            Assert.AreEqual("name", node.Name);
            Assert.AreEqual(3, node.Attributes.Count);
            Assert.AreEqual("attr1", node.Attributes[0].Name);
            Assert.AreEqual("attr2", node.Attributes[1].Name);
            Assert.AreEqual("attr3", node.Attributes[2].Name);
            Assert.AreEqual("value", node.Attributes[0].Value);
            Assert.AreEqual(null, node.Attributes[1].Value);
            Assert.AreEqual("", node.Attributes[2].Value);
            Assert.AreEqual(1, node.Flags.Count);
            Assert.AreEqual(true, node.Flags.Contains(Flags.NormalTag));
        }
Пример #2
0
        public void NormalTag()
        {
            string input = "<name>";

            TextFormatter formatter = new TextFormatter(input);

            NormalTagParser parser = new NormalTagParser(formatter);

            if (parser.CanParse())
            {
                parser.Parse();
            }

            HtmlDocumentNode node = parser.ParsedNode;

            Assert.AreEqual("name", node.Name);
            Assert.AreEqual(0, node.Attributes.Count);
            Assert.AreEqual(1, node.Flags.Count);
            Assert.AreEqual(true, node.Flags.Contains(Flags.NormalTag));
        }
Пример #3
0
        public void AttributesWithQuotesWithoutValues()
        {
            string input = "<name attr=\"\" attr2=\'\'>";

            TextFormatter formatter = new TextFormatter(input);

            NormalTagParser parser = new NormalTagParser(formatter);

            if (parser.CanParse())
            {
                parser.Parse();
            }

            HtmlDocumentNode node = parser.ParsedNode;

            Assert.AreEqual("name", node.Name);
            Assert.AreEqual(2, node.Attributes.Count);
            Assert.AreEqual("attr", node.Attributes[0].Name);
            Assert.AreEqual("attr2", node.Attributes[1].Name);
            Assert.AreEqual("", node.Attributes[0].Value);
            Assert.AreEqual("", node.Attributes[1].Value);
            Assert.AreEqual(1, node.Flags.Count);
            Assert.AreEqual(true, node.Flags.Contains(Flags.NormalTag));
        }