Пример #1
0
 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"));
 }
Пример #2
0
        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));
            }
        }
Пример #3
0
 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());
 }
Пример #4
0
        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);
        }
Пример #5
0
        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));
            }
        }