Пример #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 void VerifySingleUUPMatch()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\" .");

            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\" .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #3
0
        public void VerifySingleUUPMismatchWithLanguageByLexicalValue()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"@en .");

            verifier.Receive("<http://example/subj> <http://example/pred> \"bang\"@en .");
            Assert.IsFalse(verifier.Verify());
        }
Пример #4
0
        public void VerifierNormalisesWhitespaceBetweenExpectedTripleComponents()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj>  <http://example/pred>  <http://example/obj>  .");

            verifier.Receive("<http://example/subj> <http://example/pred> <http://example/obj> .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #5
0
        public void VerifySingleUUUMismatch()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> <http://example/obj> .");

            verifier.Receive("<http://example/subj> <http://example/pred> <http://example/obj2> .");
            Assert.IsFalse(verifier.Verify());
        }
Пример #6
0
        public void VerifySingleBUUMatchWithSameNodeId()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("_:genid1 <http://example/pred> <http://example/obj> .");

            verifier.Receive("_:genid1 <http://example/pred> <http://example/obj> .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #7
0
        public void VerifySingleBUBMatchWithDifferentNodeId()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("_:genid1 <http://example/pred> _:genid1 .");

            verifier.Receive("_:buffy <http://example/pred> _:buffy .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #8
0
        public void VerifySingleUUTMismatchByDatatype()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");

            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/foo> .");
            Assert.IsFalse(verifier.Verify());
        }
Пример #9
0
        public void VerifyConsidersDuplicateReceivedTriples()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");

            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");
            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");
            Assert.IsFalse(verifier.Verify());
        }
Пример #10
0
        public void VerifyRecievedCountMustNotBeGreaterThanExpected()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");

            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");
            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"@en .");
            Assert.IsFalse(verifier.Verify());
        }
Пример #11
0
        public void VerifyMultipleBUUMatchWithTwoNodeIdsReceiveUsesDifferentIdsOutOfOrder()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("_:genid2 <http://example/pred> <http://example.com/obj> .");
            verifier.Expect("_:genid1 <http://example/pred2> <http://example.com/obj> .");

            verifier.Receive("_:buffy1 <http://example/pred2> <http://example.com/obj> .");
            verifier.Receive("_:buffy2 <http://example/pred> <http://example.com/obj> .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #12
0
        public void VerifyMultipleUUBMatchWithTwoNodeIdsReceiveUsesDifferentIdsOutOfOrder()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> _:genid1 .");
            verifier.Expect("<http://example/subj> <http://example/pred2> _:genid2 .");

            verifier.Receive("<http://example/subj> <http://example/pred2> _:buffy2 .");
            verifier.Receive("<http://example/subj> <http://example/pred> _:buffy1 .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #13
0
        public void VerifyMultipleUUBMatchWithDifferentNodeId()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> _:genid1 .");
            verifier.Expect("<http://example/subj> <http://example/pred2> _:genid1 .");

            verifier.Receive("<http://example/subj> <http://example/pred> _:jim .");
            verifier.Receive("<http://example/subj> <http://example/pred2> _:jim .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #14
0
        public void VerifyNonBlankNodeTriplesComparedInAnyOrder()
        {
            NTripleListVerifier verifier = new NTripleListVerifier();

            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"@en .");
            verifier.Expect("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");
            verifier.Expect("<http://example/subj> <http://example/pred> <http://example/obj> .");

            verifier.Receive("<http://example/subj> <http://example/pred> <http://example/obj> .");
            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"^^<http://example.com/type> .");
            verifier.Receive("<http://example/subj> <http://example/pred> \"fizz\"@en .");
            Assert.IsTrue(verifier.Verify());
        }
Пример #15
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);
            }