-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathExamplesBase.cs
More file actions
82 lines (68 loc) · 3.1 KB
/
Copy pathExamplesBase.cs
File metadata and controls
82 lines (68 loc) · 3.1 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SignNow.Net.Model;
using SignNow.Net.Test.Context;
namespace SignNow.Net.Examples
{
[TestClass]
public abstract class ExamplesBase
{
protected DateTime UnixEpoch => new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
/// <summary>
/// Base path to the `TestExamples` directory.
/// Path should use Unix-like directory separator char. It requires for cross-platform path compatibility.
/// </summary>
protected static readonly string BaseTestExamplesPath = "../../../TestExamples/"
.Replace('/', Path.DirectorySeparatorChar);
protected static readonly string PdfWithSignatureField = Path.Combine(BaseTestExamplesPath, "DocumentWithSignatureFieldTag.pdf");
protected static readonly string PdfWithoutFields = Path.Combine(BaseTestExamplesPath, "SignAndDate.pdf");
protected static readonly string PdfWithComplexTags = Path.Combine(BaseTestExamplesPath, "ComplexTags.pdf");
/// <summary>
/// Contains application clientId, clientSecret and user credentials
/// </summary>
protected static CredentialModel credentials = new CredentialLoader(ApiBaseUrl).GetCredentials();
/// <summary>
/// signNow service container used for ExampleRunner
/// </summary>
protected static SignNowContext testContext;
/// <summary>
/// signNow API base Url (sandbox)
/// </summary>
public static Uri ApiBaseUrl => new Uri("https://api-eval.signnow.com/");
/// <summary>
/// Delete test document after test.
/// </summary>
protected void DeleteTestDocument(string disposableDocumentId)
{
if (string.IsNullOrEmpty(disposableDocumentId))
{
return;
}
var documentTask = testContext.Documents
.DeleteDocumentAsync(disposableDocumentId);
Task.WaitAll(documentTask);
Assert.IsFalse(documentTask.IsFaulted);
}
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
// If you want to use your own credentials just for simple and fast test
// uncomment next lines bellow and replace placeholders with your credentials:
// credentials = new CredentialModel
// {
// Login = "[email protected]",
// Password = "your-secret-password",
// ClientId = "your-application-client-id",
// ClientSecret = "your-application-client-secret"
// };
var client = new HttpClient();
// Create signNow context with all the services and Authorization
testContext = new SignNowContext(ApiBaseUrl, null, client);
testContext.SetAppCredentials(credentials.ClientId, credentials.ClientSecret);
testContext.GetAccessToken(credentials.Login, credentials.Password, Scope.All);
}
}
}