private void Setup_Test_Database(TestDatabase client) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("one_to_two", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("two_to_three", DirectionStep.To(VertexQuery.Find("three")))).Wait(); }
public void Steps_SimplePath() { using (var client = TestDatabase.GetClient("simple_path")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("to", DirectionStep.To(VertexQuery.Find("three")))).Wait(); Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("one").Both().Both().Count()).Result.First(), 2L); Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("one").Both().Both().SimplePath().Count()).Result.First(), 1L); } }
public void Steps_Optional() { using (var client = TestDatabase.GetClient("optional")) { client.Execute(VertexQuery.Create("one")).Wait(); var subQuery = VertexQuery.All().CreateSubQuery().Out(); Assert.AreEqual(client.Execute(VertexQuery.All().Optional(subQuery)).Result.First().label, "one"); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); Assert.AreEqual(client.Execute(VertexQuery.All().Optional(subQuery)).Result.First().label, "two"); } }
public void Steps_AddE() { using (var client = TestDatabase.GetClient("addE")) { // Setup var vertex1 = client.Execute(VertexQuery.Create("vertex1")).Result; var vertex2 = client.Execute(VertexQuery.Create("vertex2")).Result; // Test var query = VertexQuery.All().HasLabel("vertex1").AddEdge("edge1", DirectionStep.To(vertex2.First().id)); client.Execute(query).Wait(); // Verify Assert.AreEqual(client.Execute(VertexQuery.All().HasLabel("vertex1").Out()).Result.First().id, vertex2.First().id); } }
public void Steps_Where() { using (var client = TestDatabase.GetClient("where")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.Create("three")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); client.Execute(VertexQuery.All().HasLabel("two").AddEdge("to", DirectionStep.To(VertexQuery.Find("three")))).Wait(); var query = VertexQuery.All().HasLabel("one").As("a").Both().Both().Where(GraphPredicate.NotEqualTo("a")); var result = client.Execute(query).Result; Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result.First().label, "three"); } }
public void Steps_Select() { using (var client = TestDatabase.GetClient("select")) { client.Execute(VertexQuery.Create("one")).Wait(); client.Execute(VertexQuery.Create("two")).Wait(); client.Execute(VertexQuery.All().HasLabel("one").AddEdge("to", DirectionStep.To(VertexQuery.Find("two")))).Wait(); var query = VertexQuery.All().As("a").Out().As("b").Select("a", "b"); var result = client.Execute(query).Result; Assert.IsTrue(result.First().ContainsKey("a")); Assert.IsTrue(result.First().ContainsKey("b")); } }
public void Steps_ValueMap() { using (var client = TestDatabase.GetClient("valueMap")) { client.Execute(VertexQuery.Create("foo").AddProperty("age", 30)).Wait(); var vertexQuery = VertexQuery.All().ValueMap(); var vertexResult = client.Execute(vertexQuery).Result; Assert.AreEqual(vertexResult.Count(), 1); Assert.IsTrue(vertexResult.First().ContainsKey("age")); Assert.AreEqual(vertexResult.First()["age"].First(), 30L); client.Execute(VertexQuery.Create("bar")).Wait(); client.Execute(VertexQuery.All().HasLabel("foo").AddEdge("to", DirectionStep.To(VertexQuery.Find("bar"))).AddProperty("key", "value")).Wait(); var edgeQuery = VertexQuery.All().OutE().ValueMap(); var edgeResult = client.Execute(edgeQuery).Result; Assert.AreEqual(edgeResult.Count(), 1); Assert.IsTrue(edgeResult.First().ContainsKey("key")); Assert.AreEqual(edgeResult.First()["key"], "value"); } }