コード例 #1
0
        public void TripleStoreHasGraph02()
        {
            ITripleStore store = this.GetInstance();

            IGraph g = new Graph();

            store.Add(g);

            Assert.True(store.HasGraph(null));
        }
コード例 #2
0
        public void TripleStoreAdd01()
        {
            ITripleStore store = this.GetInstance();

            Graph g = new Graph();

            store.Add(g);

            Assert.False(store.IsEmpty);
            Assert.True(store.HasGraph(g.BaseUri));
        }
コード例 #3
0
        public void TripleStoreHasGraph03()
        {
            ITripleStore store = this.GetInstance();

            IGraph g = new Graph();

            g.BaseUri = new Uri("http://nosuchdomain.com/graph");
            store.Add(g);

            Assert.True(store.HasGraph(g.BaseUri));
        }
コード例 #4
0
        public void TripleStoreAdd02()
        {
            ITripleStore store = this.GetInstance();

            IGraph g = new Graph();

            g.BaseUri = new Uri("http://example.org/graph");
            store.Add(g);

            Assert.False(store.IsEmpty);
            Assert.True(store.HasGraph(g.BaseUri));
        }
コード例 #5
0
        private void AssertStoresEqual(ITripleStore expectedTripleStore, ITripleStore actualTripleStore, string testFile)
        {
            foreach (var graphUri in expectedTripleStore.Graphs.GraphUris)
            {
                if (graphUri == null)
                {
                    Assert.True(actualTripleStore.HasGraph(null),
                                $"Test failed for input {testFile}.\r\nExpected a default graph to be present.");
                    AssertGraphsEqual(expectedTripleStore[null], actualTripleStore[null],
                                      expectedTripleStore, actualTripleStore, testFile);
                }
                else if (graphUri.ToString().StartsWith("nquads:bnode:"))
                {
                    Uri matchedGraph = null;
                    foreach (var actualGraphUri in actualTripleStore.Graphs.GraphUris.Where(u =>
                                                                                            u != null && u.ToString().StartsWith("nquads:bnode:")))
                    {
                        var expectedGraph = expectedTripleStore[graphUri];
                        var actualGraph   = actualTripleStore[actualGraphUri];
                        if (actualGraph.Equals(expectedGraph, out _))
                        {
                            matchedGraph = actualGraphUri;
                            break;
                        }
                    }

                    if (matchedGraph == null)
                    {
                        var expectedLines = MakeNQuadsList(expectedTripleStore);
                        var actualLines   = MakeNQuadsList(actualTripleStore);
                        Assert.True(false,
                                    $"Test failed for input {testFile}.\r\nFailed to find a match for graph {graphUri}.\r\nExpected:\r\n{expectedLines}\r\nActual:\r\n{actualLines}");
                    }
                    else
                    {
                        actualTripleStore.Graphs.Remove(matchedGraph);
                    }
                }
                else
                {
                    if (!actualTripleStore.Graphs.Contains(graphUri))
                    {
                        var expectedLines = MakeNQuadsList(expectedTripleStore);
                        var actualLines   = MakeNQuadsList(actualTripleStore);
                        Assert.True(false,
                                    $"Test failed for input {testFile}.\r\nFailed to find a match for graph {graphUri}.\r\nExpected:\r\n{expectedLines}\r\nActual:\r\n{actualLines}");
                    }
                    AssertGraphsEqual(expectedTripleStore[graphUri], actualTripleStore[graphUri],
                                      expectedTripleStore, actualTripleStore, testFile);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Handles Triples by asserting them into the appropriate Graph creating the Graph if necessary
        /// </summary>
        /// <param name="t">Triple</param>
        /// <returns></returns>
        protected override bool HandleTripleInternal(Triple t)
        {
            if (!_store.HasGraph(t.GraphUri))
            {
                Graph g = new Graph();
                g.BaseUri = t.GraphUri;
                _store.Add(g);
            }
            IGraph target = _store[t.GraphUri];

            target.Assert(t.CopyTriple(target));
            return(true);
        }
コード例 #7
0
 /// <summary>
 /// Gets whether a Graph exists in the store.
 /// </summary>
 /// <param name="graphUri">Graph URI.</param>
 /// <returns></returns>
 public virtual bool HasGraph(Uri graphUri)
 {
     return(_store.HasGraph(graphUri));
 }
コード例 #8
0
        public void TripleStoreHasGraph01()
        {
            ITripleStore store = this.GetInstance();

            Assert.False(store.HasGraph(new Uri("http://thereisnosuchdomain.com:1234/graph")));
        }