-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPITest.cs
68 lines (57 loc) · 2.01 KB
/
APITest.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 System.Net;
using System.IO;
using System;
using Xunit;
using Skylight.Sdk;
using System.Threading.Tasks;
using Skylight.Api.Authentication.V1.UsersRequests;
namespace Skylight.Sdk.Tests
{
public class SkylightFixture : IAsyncLifetime {
public static Manager SkyManager;
public static string TestUserId;
public SkylightFixture() {
SkyManager = new Manager(Path.Join("..", "..", "..", "credentials.json"));
}
public async Task InitializeAsync()
{
await SkyManager.Connect();
//Create a default user for our tests to use
var userNew = new Skylight.Api.Authentication.V1.Models.UserNew() {
Username = "sdk.test.user." + Guid.NewGuid().ToString()
, Password = "password"
};
var userResponse = await SkyManager.ApiClient.ExecuteRequestAsync(new CreateUserRequest(userNew));
TestUserId = userResponse.Content.Id;
}
public async Task DisposeAsync()
{
//Delete our default user
await SkyManager.ApiClient.ExecuteRequestAsync(new DeleteUserRequest(TestUserId));
}
}
[CollectionDefinition("Skylight collection")]
public class SkylightCollectionFixture : ICollectionFixture<SkylightFixture> {
// This class has no code, and is never created. Its purpose is simply
// to be the place to apply [CollectionDefinition] and all the
// ICollectionFixture<> interfaces.
}
[Collection("Skylight collection")]
public abstract class APITest
{
protected SkylightFixture fixture;
public APITest(SkylightFixture fixture) {
this.fixture = fixture;
}
protected static Manager SkyManager {
get {
return SkylightFixture.SkyManager;
}
}
protected static string TestUserId {
get {
return SkylightFixture.TestUserId;
}
}
}
}