forked from coronabytes/dotnet-arangodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryStatisticTest.cs
57 lines (49 loc) · 1.87 KB
/
QueryStatisticTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Core.Arango.Protocol;
using Core.Arango.Tests.Core;
using Newtonsoft.Json;
using Xunit;
using Xunit.Abstractions;
namespace Core.Arango.Tests
{
public class QueryStatisticTest(ITestOutputHelper output) : TestBase
{
public override async Task InitializeAsync()
{
Arango =
new ArangoContext(UniqueTestRealm(),
new ArangoConfiguration
{
QueryProfile = (query, bindVars, stats) =>
{
var boundQuery = query;
foreach (var p in bindVars.OrderByDescending(x => x.Key.Length))
boundQuery = boundQuery.Replace("@" + p.Key, JsonConvert.SerializeObject(p.Value));
output.WriteLine(
$"{boundQuery}\n{JsonConvert.SerializeObject(stats, Formatting.Indented)}");
}
});
await Arango.Database.CreateAsync("test");
}
[Fact]
public async Task QueryStats()
{
await Arango.Collection.CreateAsync("test", "test", ArangoCollectionType.Document);
await Arango.Document.CreateManyAsync("test", "test", new List<Entity>
{
new() {Value = 1},
new() {Value = 2},
new() {Value = 3},
new() {Value = 4},
new() {Value = 5}
});
var select = new List<int> {1, 2, 3};
var res = await Arango.Query.ExecuteAsync<Entity>("test",
$"FOR e IN test FILTER e.Value IN {select} LIMIT 2 RETURN e", fullCount: true);
Assert.Equal(2, res.Count);
Assert.Equal(3, res.FullCount);
}
}
}