-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUnitTest1.cs
68 lines (56 loc) · 2.59 KB
/
UnitTest1.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
58
59
60
61
62
63
64
65
66
67
68
using NebulaNet;
using NUnit.Framework;
using System.Text;
using System.Threading.Tasks;
namespace NebulaNetTest
{
public class Tests
{
private static NebulaConnection _client;
private static long Session_id;
[OneTimeSetUp]
public void Setup()
{
_client = new NebulaConnection();
_client.OpenAsync("127.0.0.1", 9669).Wait();
var authResponse = _client.AuthenticateAsync("root", "123456").Result;
Session_id=authResponse.Session_id;
}
[OneTimeTearDown]
public async Task TearDown()
{
await _client.SignOutAsync(Session_id);
}
[Test]
public async Task TestAll()
{
Assert.IsTrue(Session_id > 0);
await _client.ExecuteAsync(Session_id, "ADD HOSTS \"storaged0\":9779,\"storaged1\":9779,\"storaged2\":9779");
await Task.Delay(20000);
StringBuilder sb = new StringBuilder();
sb.Append("CREATE SPACE IF NOT EXISTS test(vid_type=FIXED_STRING(30));");
sb.Append("USE test;");
sb.Append("CREATE TAG IF NOT EXISTS person(name string, age int);");
sb.Append("CREATE EDGE like (likeness double);");
var executionResponse = await _client.ExecuteAsync(Session_id,sb.ToString());
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
await Task.Delay(5000);
executionResponse = await _client.ExecuteAsync(Session_id, "INSERT VERTEX person(name, age) VALUES \"Bob\":(\"Bob\", 10), \"Lily\":(\"Lily\", 9);");
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
executionResponse = await _client.ExecuteAsync(Session_id, "INSERT EDGE like(likeness) VALUES \"Bob\"->\"Lily\":(80.0);");
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
executionResponse = await _client.ExecuteAsync(Session_id, "FETCH PROP ON person \"Bob\" YIELD vertex as node;");
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
executionResponse = await _client.ExecuteAsync(Session_id, "FETCH PROP ON like \"Bob\"->\"Lily\" YIELD edge as e;");
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
executionResponse = await _client.ExecuteAsync(Session_id, "DROP SPACE test;");
await Task.Delay(5000);
Assert.IsTrue(executionResponse.Error_code == 0);
}
}
}