Example #1
0
        public void GetStatementEnumerator()
        {
            Node theSubject      = new NodeStub("http://example.com/subj");
            Arc  thePredicate    = new UriRef("http://example.com/pred");
            Node theFirstObject  = new UriRef("http://example.com/obj1");
            Node theSecondObject = new UriRef("http://example.com/obj2");

            Statement   statement1 = new Statement(new BlankNode(), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj1"));
            Statement   statement2 = new Statement(new BlankNode(), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj2"));
            TripleStore store      = MakeNewTripleStore();

            store.Add(statement1);
            store.Add(statement2);

            ResourceStatement resStatement1 = new ResourceStatement(store.GetResourceDenotedBy(statement1.GetSubject()), store.GetResourceDenotedBy(statement1.GetPredicate()), store.GetResourceDenotedBy(statement1.GetObject()));
            ResourceStatement resStatement2 = new ResourceStatement(store.GetResourceDenotedBy(statement2.GetSubject()), store.GetResourceDenotedBy(statement2.GetPredicate()), store.GetResourceDenotedBy(statement2.GetObject()));
            IEnumerator       statementEnum = store.GetStatementEnumerator();

            Assert.IsTrue(statementEnum.MoveNext(), "Enumerator has first statement");

            ResourceStatement firstStatement = (ResourceStatement)statementEnum.Current;

            Assert.IsTrue(statementEnum.MoveNext(), "Enumerator has second statement");

            ResourceStatement secondStatement = (ResourceStatement)statementEnum.Current;

            Assert.IsFalse(statementEnum.MoveNext());
            Assert.IsTrue((firstStatement.Equals(resStatement1) && secondStatement.Equals(resStatement2)) || (firstStatement.Equals(resStatement2) && secondStatement.Equals(resStatement1)), "Statements have correct components");
            store.Clear();
        }
Example #2
0
        public void GetObject()
        {
            NodeStub theSubject   = new NodeStub("theSubject");
            UriRef   thePredicate = new UriRef("thePredicate");
            NodeStub theObject    = new NodeStub("theObject");

            Statement statement = new Statement(theSubject, thePredicate, theObject);

            Assert.AreSame(theObject, statement.GetObject());
        }
Example #3
0
        public void AddDistinguishesDifferentBlankNodeInstances()
        {
            Node theSubject      = new NodeStub("http://example.com/subj");
            Arc  thePredicate    = new UriRef("http://example.com/pred");
            Node theFirstObject  = new UriRef("http://example.com/obj1");
            Node theSecondObject = new UriRef("http://example.com/obj2");

            TripleStore store = MakeNewTripleStore();

            store.Add(new Statement(new BlankNode(), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj1")));
            store.Add(new Statement(new BlankNode(), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj2")));

            TripleStoreVerifier verifier = new TripleStoreVerifier();

            verifier.expect("_:node1 <http://example.com/pred> <http://example.com/obj1> .");
            verifier.expect("_:node2 <http://example.com/pred> <http://example.com/obj2> .");

            Assert.IsTrue(verifier.verify(store));
            store.Clear();
        }