Skip to content

Commit

Permalink
add traversal in edges tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ra0o0f committed Oct 22, 2016
1 parent 245c39b commit baf47fa
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/ArangoDB.Client.Examples/Linq/TraversalQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,61 @@ public void TraversalFilter()
.Where(g => AQL.Length(
db.Query().For(_ => g.Path.Vertices)
.Where(v => v.Id == charlie.Id)
.Select(v => v))
.Select(v => v))
== 0)
.Select(g => g.Vertex)
.ToList();

Assert.Equal(result.Count, 2);
}

[Fact]
public void TraversalInEdges()
{
InitiateGraph();

var result = db.Query()
.Traversal<Person, Follow>(alice.Id)
.Depth(1, 4)
.OutBound()
.Edge(db.NameOf<Follow>())
.Select(g => g)
.ToList();

Assert.Equal(result.Count, 4);
}


[Fact]
public void TraversalInEdgesInBound()
{
InitiateGraph();

var result = db.Query()
.Traversal<Person, Follow>(alice.Id)
.Depth(1, 4)
.OutBound()
.Edge(db.NameOf<Follow>(), EdgeDirection.Inbound)
.Select(g => g)
.ToList();

Assert.Equal(result.Count, 0);
}

[Fact]
public void TraversalInEdgesAnyDirection()
{
InitiateGraph();

var result = db.Query()
.Traversal<Person, Follow>(alice.Id)
.Depth(1, 4)
.OutBound()
.Edge(db.NameOf<Follow>(), EdgeDirection.Any)
.Select(g => g)
.ToList();

Assert.Equal(result.Count, 4);
}
}
}
44 changes: 44 additions & 0 deletions src/ArangoDB.Client.Test/Linq/TraversalQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,49 @@ public void TraversalOptions()
in 1..5 outbound @P1 graph ""SocialGraph"" options {""bfs"":true}
return { `vertex` : `graph_0_Vertex`, `edge` : `graph_0_Edge`, `path` : `graph_0_Path` }".RemoveSpaces());
}

[Fact]
public void TraversalInEdges()
{
var db = DatabaseGenerator.Get();

var query = db.Query()
.Traversal<Person, Friend>("Person/1234")
.Depth(1, 5)
.OutBound()
.Edge(db.NameOf<Friend>())
.Edge(db.NameOf<Flight>())
.Select(g => g)
.GetQueryData();

Assert.Equal(query.Query.RemoveSpaces(), @"
for `graph_0_Vertex`, `graph_0_Edge`, `graph_0_Path`
in 1..5 outbound @P1 `Friend`, `Flight`
return { `vertex` : `graph_0_Vertex`, `edge` : `graph_0_Edge`, `path` : `graph_0_Path` }".RemoveSpaces());

Assert.Equal(query.BindVars[0].Value, "Person/1234");
}

[Fact]
public void TraversalInEdgesWithDirection()
{
var db = DatabaseGenerator.Get();

var query = db.Query()
.Traversal<Person, Friend>("Person/1234")
.Depth(1, 5)
.OutBound()
.Edge(db.NameOf<Friend>(), EdgeDirection.Inbound)
.Edge(db.NameOf<Flight>())
.Select(g => g)
.GetQueryData();

Assert.Equal(query.Query.RemoveSpaces(), @"
for `graph_0_Vertex`, `graph_0_Edge`, `graph_0_Path`
in 1..5 outbound @P1 inbound `Friend`, `Flight`
return { `vertex` : `graph_0_Vertex`, `edge` : `graph_0_Edge`, `path` : `graph_0_Path` }".RemoveSpaces());

Assert.Equal(query.BindVars[0].Value, "Person/1234");
}
}
}

0 comments on commit baf47fa

Please sign in to comment.