public void RdfUpdate_AvailableInGraph() { var f = new NodeFactory(); var rdf = new RdfData(f); var g1 = f.BlankSelf(); var g2 = f.BlankSelf(); var graphPreUpdates = rdf.GetGraph(g1, g2); //add directly via rdf data. var sub = rdf.Uri("x:/s1"); var pred = rdf.Uri("x:/p1"); var val = rdf.New("text"); rdf.Assert(g1, sub, pred, val); rdf.Assert(g2, sub, pred, val); //immediately have the owned quad, //but not the data from other graph. Assert.AreEqual(1, graphPreUpdates.Query.Count, "Got the new entry"); var graphReInit = rdf.GetGraph(g1, g2); Assert.AreEqual(2, graphReInit.Query.Count, "Re-access graph gets latest"); }
public void GraphNodeReused() { var f = new NodeFactory(); var n1 = f.BlankSelf("g1"); var n2 = f.BlankSelf("g1"); Assert.AreEqual(n1, n2); }
public void GraphNode() { var f = new NodeFactory(); var g1 = f.BlankSelf(); var g2 = f.BlankSelf("g2"); Assert.IsTrue(g1.IsSelfScoped()); Assert.IsTrue(g1.Label.StartsWith(NodeFactory.BlankGraphPrefix)); Assert.IsTrue(g2.IsSelfScoped()); Assert.IsTrue(g2.Label == "g2"); }
public void Blank_NewAutoNoCollide() { var f = new NodeFactory(); var g = f.BlankSelf(); var n1 = f.Blank(g, "auto#1"); var n2 = f.Blank(g); Assert.IsFalse(n1 == n2, "Auto blank not same if label matches"); }
public void Blank_ReuseAuto() { var f = new NodeFactory(); var g = f.BlankSelf(); var n1 = f.Blank(g); var n2 = f.Blank(g, n1.Value.Label); Assert.AreEqual(n1, n2, "matching auto matches node"); }
public void BlankNode_ScopeToGraph() { var f = new NodeFactory(); //blanks in a scope can be found via same label. // but different scope, with same label in not the same blank. var g1 = f.BlankSelf(); var g2 = f.BlankSelf(); var b1 = f.Blank(g1, "A"); var b2 = f.Blank(g2, "A"); Assert.IsFalse(b1 == b2); //same scope and label will match. var b3 = f.Blank(g1, "A"); Assert.AreEqual(b1, b3); }
public void SameTriple_() { var f = new NodeFactory(); var t1 = new Quad(f.BlankSelf("g1"), f.Uri("x:s1"), f.Uri("x:/p1"), f.New("0", "xs:int")); var t2 = new Quad(f.BlankSelf("g2"), t1.Subject, t1.Predicate, t1.Object); var target = new SameTriple(); Assert.IsTrue(target.Equals(t1, t2), "Different graph and extra data, but same triple"); var t3 = new Quad(t1.Graph, t1.Subject, f.Uri("x:/other"), t1.Object); Assert.IsFalse(target.Equals(t1, t3), "Differ by predicate"); }
public void SameQuad_() { var f = new NodeFactory(); var q1 = new Quad(f.BlankSelf(), f.Uri("x:/s"), f.Uri("x:/p"), f.New("a")); var q2 = new Quad(q1.Graph, q1.Subject, f.Uri("x:/p"), q1.Object); var target = new SameQuad(); Assert.IsTrue(target.Equals(q1, q2)); }
public void BlankNodes() { var f = new NodeFactory(); var g = f.BlankSelf(); var labeled = f.Blank(g, "anon"); Assert.IsTrue(labeled.GetValueString().EndsWith("anon"), "Expect blank with label."); var auto = f.Blank(g); Assert.IsTrue(auto.GetValueString().Contains(NodeFactory.BlankNodePrefix), "Has standard prefix."); Assert.IsTrue(f.Blank(g, "_:xxA").GetValueString().EndsWith("xxA"), "Blank node with label"); Assert.IsTrue(f.Blank(g, $"{NodeFactory.BlankNodePrefix}ABc") .GetValueString().EndsWith("ABc"), "blank node with full prefix"); }
public void SubjectCanBeUriOrBlank() { var f = new NodeFactory(); var g = f.BlankSelf(); var s1 = f.Blank(g, "_:node1"); Assert.AreEqual("node1", s1.Value.Label); var s2 = f.Blank(g); Assert.IsNotNull(s2.Value.Label, "generates new label"); var s3 = f.Uri("x:/someone#here"); Assert.IsNull(s3.Value.Label); Assert.IsNull(s3.Value.Scope); Assert.ThrowsException <InvalidUri>(() => f.Uri("23:/path")); }
public void AddWithUpDownAndLet() { var f = new NodeFactory(); var rdf = new RdfData(f); var gId = f.BlankSelf("g1"); var g = rdf.GetGraph(gId).Update; // _:1 x:p1 "1". g.ForBlank("1", out _) .With(f.Uri("x:p1")) .Add(f.New("1")) // _:1 x:p2 "123" .Then().With(f.Uri("x:p2")).Add(f.New("123")) // _:1 x:p3 _:2 // _:2 x:p3 "fred" .Then().With(f.Uri("x:p3")).To(f.Blank(gId)) .With(f.Uri("x:p3")).Add(f.New("fred")) //get ref to _:2 .Then().Let(out _); }