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); }
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); }
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); }
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"); }
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); }
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"); }
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)); }
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)); }