public bool verify(KnowledgeBase knowledge) { NTripleListVerifier verifier = new NTripleListVerifier(); foreach (string nTriple in itsTriples) { verifier.Expect(nTriple); } StringWriter received = new StringWriter(); NTripleWriter writer = new NTripleWriter(received); knowledge.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); }
public void acidTest() { SimpleModel expectedModel = new SimpleModel(new XsltParserFactory()); expectedModel.ParseString(COMPLEX_DOCUMENT, "http://example.com/"); /* * RdfXmlWriter rdfWriterDump = new RdfXmlWriter( new XmlWriterDumper() ); * expectedModel.write( rdfWriterDump ); */ StringWriter outputWriter = new StringWriter(); XmlTextWriter xmlWriter = new XmlTextWriter(outputWriter); RdfXmlWriter rdfWriter = new RdfXmlWriter(xmlWriter); // Pass the expected triples through the writer expectedModel.Write(rdfWriter); SimpleModel receivedModel = new SimpleModel(new XsltParserFactory()); receivedModel.ParseString(outputWriter.ToString(), "http://example.com/"); /* * Console.WriteLine(); * Console.WriteLine( outputWriter.ToString() ); * Console.WriteLine(); */ NTripleListVerifier verifier = new NTripleListVerifier(); foreach (string ntriple in expectedModel) { verifier.Expect(ntriple); } foreach (string ntriple in receivedModel) { verifier.Receive(ntriple); } // NTripleListVerifier can't do full verify with large numbers of blank nodes Assert.IsTrue(verifier.VerifyCounts()); }