Ejemplo n.º 1
0
        public void TestExistsNodeWithInvalidAttribute()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span class='col'>test</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.ExistsNode("//span", "id");

            // Arrange
            Assert.IsFalse(result);
        }
Ejemplo n.º 2
0
        public void TestExistsNodeWithInvalidXPath()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span>test</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.ExistsNode("//div", null);

            // Arrange
            Assert.IsFalse(result);
        }
Ejemplo n.º 3
0
        public void TestExistsNode()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span>test</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.ExistsNode("//span", null);

            // Arrange
            Assert.IsTrue(result);
        }
Ejemplo n.º 4
0
        public void TestGetDocumentValue()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span>test</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.GetDocumentValue("//span", null);

            // Arrange
            Assert.AreEqual(result, "test");
        }
Ejemplo n.º 5
0
        public void TestTestSchemaWithXsd()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span col='red'>test1</span>
                        <span col='yellow'>test2</span>
                        <span col='blue'>test3</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            doc.TestSchemaWithXsd(null);
        }
Ejemplo n.º 6
0
        public void TestGetDocumentValueWithAttribute()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span class='col'>test</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.GetDocumentValue("//span", "class");

            // Arrange
            Assert.AreEqual(result, "col");
        }
Ejemplo n.º 7
0
        public void TestGetDocumentValuesWithAttribute()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span col='red'>test1</span>
                        <span col='yellow'>test2</span>
                        <span col='blue'>test3</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.GetDocumentValues("//span", "col");

            // Arrange
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("red", result.ElementAt(0));
            Assert.AreEqual("yellow", result.ElementAt(1));
            Assert.AreEqual("blue", result.ElementAt(2));
        }
Ejemplo n.º 8
0
        public void TestGetDocumentValues()
        {
            // Arrange
            const string contents =
                @"<html>
                    <body>
                        <span>test1</span>
                        <span>test2</span>
                        <span>test3</span>
                    </body>
                  </html>";
            var doc = new HtmlParser(contents);

            // Act
            var result = doc.GetDocumentValues("//span", null);

            // Arrange
            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("test1", result.ElementAt(0));
            Assert.AreEqual("test2", result.ElementAt(1));
            Assert.AreEqual("test3", result.ElementAt(2));
        }