public void AcceptanceTest_CharlesRobertDarwin() { var parser = new RDFaParser(); var triples = parser.ParseRDFTriplesFromFile("Resource\\CharlesRobertDarwin.html"); foreach (var rdfTriple in triples) { Console.WriteLine(string.Format("{0} {1} {2}", rdfTriple.Subject, rdfTriple.Predicate, rdfTriple.Objecto)); } }
public void WriteToXML_WithValidTripes_ExpectedFileCanBeFoundInExpectedLocation() { var parser = new RDFaParser(); var writer = new RDFWriter(); var triples = parser.ParseRDFTriplesFromFile("Resource\\alice-example.html"); if (File.Exists("sample.rdf")) File.Delete("sample.rdf"); writer.WriteToXML(triples, "out\\sample.rdf"); Assert.IsTrue(File.Exists("out\\sample.rdf")); }
public void AcceptanceTest_Alice_Example() { var parser = new RDFaParser(); var triples = parser.ParseRDFTriplesFromFile("Resource\\alice-example.html"); var builder = new StringBuilder(); foreach (var rdfTriple in triples) { builder.AppendLine(string.Format("{0} {1} {2}", rdfTriple.Subject, rdfTriple.Predicate, rdfTriple.Objecto)); } //File.WriteAllText("out\\out.put", builder.ToString()); Console.Write(builder.ToString()); }
public void AcceptanceTest_HTML_5_RDFa_1_1() { var parser = new RDFaParser(); var triples = parser.ParseRDFTriplesFromFile("Resource\\HTML_5_RDFa_1_1.html"); foreach (var rdfTriple in triples) { Console.WriteLine(string.Format("<{0}> <{1}> <{2}>", rdfTriple.Subject, rdfTriple.Predicate, rdfTriple.Objecto)); } Assert.IsNotNull(triples); Assert.AreEqual(7, triples.Count); Assert.AreEqual("http://example.org/john-d/", triples[0].Subject); Assert.AreEqual("http://purl.org/dc/elements/1.1/creator", triples[0].Predicate); Assert.AreEqual("Jonathan Doe", triples[0].Object.Literal); Assert.AreEqual("http://example.org/john-d/", triples[1].Subject); Assert.AreEqual("http://xmlns.com/foaf/0.1/primaryTopic", triples[1].Predicate); Assert.AreEqual("http://example.org/john-d/#me", triples[1].Object.Uri); Assert.AreEqual("http://example.org/john-d/#me", triples[2].Subject); Assert.AreEqual("http://xmlns.com/foaf/0.1/nick", triples[2].Predicate); Assert.AreEqual("John D", triples[2].Object.Literal); Assert.AreEqual("http://example.org/john-d/#me", triples[3].Subject); Assert.AreEqual("http://xmlns.com/foaf/0.1/interest", triples[3].Predicate); Assert.AreEqual("http://www.neubauten.org/", triples[3].Object.Uri); Assert.AreEqual("http://example.org/john-d/#me", triples[4].Subject); Assert.AreEqual("http://xmlns.com/foaf/0.1/interest", triples[4].Predicate); Assert.AreEqual("urn:ISBN:0752820907", triples[4].Object.Uri); Assert.AreEqual("urn:ISBN:0752820907", triples[5].Subject); Assert.AreEqual("http://purl.org/dc/elements/1.1/title", triples[5].Predicate); Assert.AreEqual("Weaving the Web", triples[5].Object.Literal); Assert.AreEqual("urn:ISBN:0752820907", triples[6].Subject); Assert.AreEqual("http://purl.org/dc/elements/1.1/creator", triples[6].Predicate); Assert.AreEqual("Tim Berners-Lee", triples[6].Object.Literal); }
public void AcceptanceTest_IMDB_The_Rock() { var parser = new RDFaParser(); var triples = parser.ParseRDFTriplesFromFile("Resource\\IMDB_The_Rock.html").Where(x => x.Subject != null && x.Predicate != null).ToList(); foreach (var rdfTriple in triples) { Console.WriteLine(string.Format("{0} {1} {2}", rdfTriple.Subject, rdfTriple.Predicate, rdfTriple.Objecto)); } }
public void UpdateUriMappings_WithValidElementNode_RetrunsExpectedMappings_2() { // Arrange var parser = new RDFaParser(); var context = _testContext.GetParserContext(); var element = _testContext.GetElement("Resource\\alice-example.html", "//head"); // Act var response = parser.UpdatePrefixMappings(context, element); // Assert Assert.IsNotNull(response); Assert.AreEqual(1, response.Count); Assert.AreEqual("http://ogp.me/ns#", response["og"]); Assert.AreEqual(context.PrefixMappings, response); }
public void UpdateDefaultVocabulary_ElementWithVocab_UpdatesContextDefaultVocabulary() { // Arrange var parser = new RDFaParser(); var context = _testContext.GetParserContext(); var element = _testContext.GetElement("Resource\\alice-example.html", "//body"); // Act var result = parser.UpdateDefaultVocabulary(context, element); // Assert Assert.AreEqual("http://purl.org/dc/terms/", result); }
public void UpdateDefaultVocabulary_ElementAndAnsestorsDoesNotHaveVocab_ReturnNull() { // Arrange var parser = new RDFaParser(); var context = _testContext.GetParserContext(); context.DefaultVocabulary = "http://purl.org/dc/terms/"; var element = _testContext.GetElement("Resource\\alice-example.html", "//head"); // Act var result = parser.UpdateDefaultVocabulary(context, element); // Assert Assert.IsNull(result); }
public void GetDocNamespaces_WithValidDocuments_RetrunsExpectedNameSpaceMappings() { // Arrange var parser = new RDFaParser(); var document = _testContext.GetHtmlDocument("Resource\\XHTML+RDFa 1.0.html"); // Act var response = parser.GetDocNamespaces(document); // Assert Assert.AreEqual(2, response.Count); Assert.AreEqual("http://xmlns.com/foaf/0.1/", response["foaf"]); Assert.AreEqual("http://purl.org/dc/elements/1.1/", response["dc"]); }
public void GetBaseURI_WithHtmlNode_ReturnsExpectedBaseURI() { // Arrange var parser = new RDFaParser(); var element = _testContext.GetHtmlDocument("Resource\\alice-example.html"); // Act var result = parser.GetBaseURI(element); // Assert Assert.AreEqual("http://example.com/", result); }
public void AcceptanceTest_WebLink() { var parser = new RDFaParser(); //var triples = parser.GetRDFTriplesFromURL("http://www.3kbo.com/examples/rdfa/simple.html"); var triples = parser.ParseRDFTriplesFromURL("http://www.bbc.co.uk/"); foreach (var rdfTriple in triples) { Console.WriteLine(string.Format("{0} {1} {2}", rdfTriple.Subject, rdfTriple.Predicate, rdfTriple.Objecto)); } }