Пример #1
0
        public void NodeCountGet()
        {
            TagDocument target = new TagDocument("This is a test");

            target._nodeCount = 5;
            Assert.AreEqual(5, target.NodeCount);
        }
Пример #2
0
        public HtmlElement CreateElement(string html)
        {
            _tagIndeces.Clear();
            _firstInvalidNode = null;
            _htmlSource       = html;
            _htmlElementStack = new Stack <HtmlElement>();
            _htmlElementStack.Push(null);


            Parser parser = new Parser();

            parser.IgnoreCase = true;

            TagDocument tagDocument = parser.Parse(html, 0, false);

            if (tagDocument.Nodes.Count > 1)
            {
                throw new WebTestException("More than one root element is not allowed in the source html when building an HtmlElement.");
            }

            HtmlElement newElement = GenerateHtmlElement((NodeContainer)tagDocument.Nodes[0]);

            if (_ensureValidMarkup && parser.HasInvalidMarkup)
            {
                throw new WebTestException(String.Format("The parsed html source has invalid markup at start position {0}.", _firstInvalidNode.StartPosition));
            }

            return(newElement);
        }
Пример #3
0
        public void DocumentGet()
        {
            Node target = CreateNode();

            Assert.IsNull(target.Document);
            TagDocument doc = new TagDocument("This is a test");

            target.SetParent(doc);
            Assert.AreEqual("This is a test", target.Document.Text);
        }
Пример #4
0
        public void TypeGet()
        {
            TagDocument target = new TagDocument(string.Empty);

            Assert.AreEqual(NodeType.Document, target.Type);
        }
Пример #5
0
        public void DocumentGet()
        {
            TagDocument target = new TagDocument("This is a test");

            Assert.AreEqual(target, target.Document);
        }
Пример #6
0
        public void TextGet()
        {
            TagDocument target = new TagDocument("This is a test");

            Assert.AreEqual("This is a test", target.Text);
        }