예제 #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);
        }
예제 #2
0
            public bool Run()
            {
                string failureDescription = "";

                NTripleListVerifier verifier             = new NTripleListVerifier();
                FileStream          expectedStream       = new FileStream(itsOutputFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                StreamReader        expectedStreamReader = new StreamReader(expectedStream);

                string expectedLine = expectedStreamReader.ReadLine();

                while (expectedLine != null)
                {
                    string trimmed = expectedLine.Trim();
                    if (trimmed.Length > 0 && !trimmed.StartsWith("#"))
                    {
                        verifier.Expect(trimmed);
                    }
                    expectedLine = expectedStreamReader.ReadLine();
                }


                FileStream inputStream = new FileStream(itsInputFileName, FileMode.Open, FileAccess.Read, FileShare.Read);

                bool testPassed = false;

                try {
                    SimpleModel model = new SimpleModel(itsParserFactory);
                    model.Parse(inputStream, itsBaseUri);

                    foreach (string ntriple in model)
                    {
                        verifier.Receive(ntriple);
                    }

                    testPassed         = verifier.Verify();
                    failureDescription = verifier.GetLastFailureDescription() + "\r\nTriples received:\r\n" + model.ToString();
                }
                catch (Exception e) {
                    failureDescription = "Parse exception: " + e;
                }

                if (!testPassed)
                {
                    itsFailureDescription = "FAILED " + itsBaseUri + "\r\nReason: " + failureDescription + "\r\n";
                }
                return(testPassed);
            }