-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLoadJsonTest.cs
60 lines (51 loc) · 1.89 KB
/
LoadJsonTest.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
using System;
using System.Threading.Tasks;
using Xunit;
namespace RelationalAI.Test
{
public class LoadJsonTests : UnitTest
{
public static string Uuid = Guid.NewGuid().ToString();
public static string Dbname = $"csharp-sdk-{Uuid}";
public static string EngineName = $"csharp-sdk-{Uuid}";
private const string Sample = "{" +
"\"name\":\"Amira\",\n" +
"\"age\":32,\n" +
"\"height\":null,\n" +
"\"pets\":[\"dog\",\"rabbit\"]}";
[Fact]
public async Task LoadJsonTest()
{
var client = CreateClient();
await client.CreateEngineWaitAsync(EngineName);
await client.CreateDatabaseAsync(Dbname, EngineName);
var loadRsp = await client.LoadJsonAsync(Dbname, EngineName, "sample", Sample);
Assert.Equal(TransactionAsyncState.Completed, loadRsp.Transaction.State);
Assert.Empty(loadRsp.Problems);
// FIXME: complete the test implementation
// when this issue https://github.com/RelationalAI/rai-sdk-csharp/issues/25
// is fixed
//var rsp = await client.ExecuteAsync(Dbname, EngineName, "def output = sample");
}
public override async Task DisposeAsync()
{
var client = CreateClient();
try
{
await client.DeleteDatabaseAsync(Dbname);
}
catch (Exception e)
{
await Console.Error.WriteLineAsync(e.ToString());
}
try
{
await client.DeleteEngineWaitAsync(EngineName);
}
catch (Exception e)
{
await Console.Error.WriteLineAsync(e.ToString());
}
}
}
}