-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathAbstractItClientTest.cs
55 lines (46 loc) · 1.5 KB
/
AbstractItClientTest.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
using System;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using InfluxDB.Client.Api.Domain;
using InfluxDB.Client.Core.Test;
using NUnit.Framework;
namespace InfluxDB.Client.Test
{
public class AbstractItClientTest : AbstractTest
{
protected InfluxDBClient Client;
protected string InfluxDbUrl;
[SetUp]
public new void SetUp()
{
InfluxDbUrl = GetInfluxDb2Url();
if (!TestContext.CurrentContext.Test.Properties.ContainsKey("basic_auth"))
{
Client = InfluxDBClientFactory.Create(InfluxDbUrl, "my-token");
}
else
{
Client = InfluxDBClientFactory.Create(InfluxDbUrl, "my-user", "my-password".ToCharArray());
}
}
[TearDown]
protected void After()
{
Client.Dispose();
}
public static string GenerateName(string prefix)
{
Assert.IsNotEmpty(prefix);
return prefix + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.ffffff",
CultureInfo.InvariantCulture) + "-IT";
}
protected async Task<Organization> FindMyOrg()
{
var org = (await Client.GetOrganizationsApi().FindOrganizationsAsync(100))
.FirstOrDefault(organization => organization.Name.Equals("my-org"));
Assert.IsNotNull(org, "my-org is required for integration tests");
return org;
}
}
}