Beispiel #1
0
        public bool verify(TripleStore store)
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            foreach (string nTriple in itsTriples)
            {
                verifier.Expect(nTriple);
            }

            StringWriter  received = new StringWriter();
            NTripleWriter writer   = new NTripleWriter(received);

            store.Write(writer);

            StringReader receivedReader = new StringReader(received.ToString());
            string       receivedLine   = receivedReader.ReadLine();

            while (receivedLine != null)
            {
                string trimmed = receivedLine.Trim();
                if (trimmed.Length > 0 && !trimmed.StartsWith("#"))
                {
                    verifier.Receive(trimmed);
                }
                receivedLine = receivedReader.ReadLine();
            }

            bool verifyResult = verifier.Verify();

            lastFailureDescription = verifier.GetLastFailureDescription();
            return(verifyResult);
        }
Beispiel #2
0
        public void writeCallsWriterEndOutputOnce()
        {
            RdfWriterCounter writer = new RdfWriterCounter();
            TripleStore      store  = MakeNewTripleStore();

            store.Write(writer);

            Assert.AreEqual(1, writer.EndOutputCalled);
            store.Clear();
        }
Beispiel #3
0
        public void ReadAndWriteRdf()
        {
            StringReader reader = new StringReader("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"><rdf:Description rdf:about=\"http://example.org/node\"><rdf:type rdf:resource=\"http://example.org/type\"/></rdf:Description></rdf:RDF>");

            TripleStore store = MakeNewTripleStore();

            SemPlan.Spiral.Core.ParserFactory parserFactory = new SemPlan.Spiral.XsltParser.XsltParserFactory();
            SemPlan.Spiral.Core.Parser        parser        = parserFactory.MakeParser(new ResourceFactory(), new StatementFactory());

            parser.NewStatement += store.GetStatementHandler();
            parser.Parse(reader, "http://example.org/node");
            parser.NewStatement -= store.GetStatementHandler();

            StringWriter  output = new StringWriter();
            NTripleWriter writer = new NTripleWriter(output);

            store.Write(writer);

            Assert.AreEqual("<http://example.org/node> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/type> .\r\n", output.ToString());
            store.Clear();
        }
Beispiel #4
0
 public virtual void Write(RdfWriter writer)
 {
     itsAssertions.Write(writer);
 }