Skip to content

Commit f22fc4b

Browse files
committed
Reformat use file-scoped namespaces
1 parent 41ad8a0 commit f22fc4b

58 files changed

Lines changed: 2509 additions & 2567 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/SignhostAPIClient.Tests/LevelEnumConverterTests.cs

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,73 @@
66
using System.Collections.Generic;
77
using Xunit;
88

9-
namespace Signhost.APIClient.Rest.Tests
9+
namespace Signhost.APIClient.Rest.Tests;
10+
11+
public class LevelEnumConverterTests
1012
{
11-
public class LevelEnumConverterTests
13+
[Fact]
14+
public void when_Level_is_null_should_deserialize_to_null()
1215
{
13-
[Fact]
14-
public void when_Level_is_null_should_deserialize_to_null()
15-
{
16-
// Arrange
17-
const string json = "{\"Type\":\"eIDAS Login\",\"Level\":null}";
16+
// Arrange
17+
const string json = "{\"Type\":\"eIDAS Login\",\"Level\":null}";
1818

19-
// Act
20-
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
19+
// Act
20+
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
2121

22-
// Assert
23-
eidasLogin.Level.Should().Be(null);
24-
}
22+
// Assert
23+
eidasLogin.Level.Should().Be(null);
24+
}
2525

26-
[Fact]
27-
public void when_Level_is_not_supplied_should_deserialize_to_null()
28-
{
29-
// Arrange
30-
const string json = "{\"Type\":\"eIDAS Login\"}";
26+
[Fact]
27+
public void when_Level_is_not_supplied_should_deserialize_to_null()
28+
{
29+
// Arrange
30+
const string json = "{\"Type\":\"eIDAS Login\"}";
3131

32-
// Act
33-
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
32+
// Act
33+
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
3434

35-
// Assert
36-
eidasLogin.Level.Should().Be(null);
37-
}
35+
// Assert
36+
eidasLogin.Level.Should().Be(null);
37+
}
3838

39-
[Fact]
40-
public void when_Level_is_unknown_should_deserialize_to_Unknown_Level()
41-
{
42-
// Arrange
43-
const string json = "{\"Type\":\"eIDAS Login\",\"Level\":\"foobar\"}";
39+
[Fact]
40+
public void when_Level_is_unknown_should_deserialize_to_Unknown_Level()
41+
{
42+
// Arrange
43+
const string json = "{\"Type\":\"eIDAS Login\",\"Level\":\"foobar\"}";
4444

45-
// Act
46-
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
45+
// Act
46+
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
4747

48-
// Assert
49-
eidasLogin.Level.Should().Be(Level.Unknown);
50-
}
48+
// Assert
49+
eidasLogin.Level.Should().Be(Level.Unknown);
50+
}
5151

52-
[Theory]
53-
[ClassData(typeof(LevelTestData))]
54-
public void when_Level_is_valid_should_deserialize_to_correct_value(Level level)
55-
{
56-
// Arrange
57-
string json = $"{{\"Type\":\"eIDAS Login\",\"Level\":\"{level}\"}}";
52+
[Theory]
53+
[ClassData(typeof(LevelTestData))]
54+
public void when_Level_is_valid_should_deserialize_to_correct_value(Level level)
55+
{
56+
// Arrange
57+
string json = $"{{\"Type\":\"eIDAS Login\",\"Level\":\"{level}\"}}";
5858

59-
// Act
60-
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
59+
// Act
60+
var eidasLogin = JsonSerializer.Deserialize<EidasLoginVerification>(json, SignhostJsonSerializerOptions.Default);
6161

62-
// Assert
63-
eidasLogin.Level.Should().Be(level);
64-
}
62+
// Assert
63+
eidasLogin.Level.Should().Be(level);
64+
}
6565

66-
private class LevelTestData
67-
: IEnumerable<object[]>
66+
private class LevelTestData
67+
: IEnumerable<object[]>
68+
{
69+
public IEnumerator<object[]> GetEnumerator()
6870
{
69-
public IEnumerator<object[]> GetEnumerator()
70-
{
71-
foreach (var value in Enum.GetValues(typeof(Level))) {
72-
yield return new[] { value };
73-
}
71+
foreach (var value in Enum.GetValues(typeof(Level))) {
72+
yield return new[] { value };
7473
}
75-
76-
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
7774
}
75+
76+
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
7877
}
7978
}

src/SignhostAPIClient.Tests/PostbackTests.cs

Lines changed: 104 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +6,111 @@
66
using SignhostAPIClient.Tests.JSON;
77
using Xunit;
88

9-
namespace Signhost.APIClient.Rest.Tests
9+
namespace Signhost.APIClient.Rest.Tests;
10+
11+
public class PostbackTests
1012
{
11-
public class PostbackTests
13+
[Fact]
14+
public void PostbackTransaction_should_get_serialized_correctly()
1215
{
13-
[Fact]
14-
public void PostbackTransaction_should_get_serialized_correctly()
15-
{
16-
string json = JsonResources.MockPostbackValid;
17-
var postbackTransaction = JsonSerializer.Deserialize<PostbackTransaction>(json, SignhostJsonSerializerOptions.Default);
18-
19-
postbackTransaction.Id .Should().Be("b10ae331-af78-4e79-a39e-5b64693b6b68");
20-
postbackTransaction.Status .Should().Be(TransactionStatus.InProgress);
21-
postbackTransaction.Seal .Should().BeTrue();
22-
postbackTransaction.Reference .Should().Be("Contract #123");
23-
postbackTransaction.PostbackUrl .Should().Be("https://example.com/postback.php");
24-
postbackTransaction.SignRequestMode .Should().Be(2);
25-
postbackTransaction.DaysToExpire .Should().Be(30);
26-
postbackTransaction.SendEmailNotifications.Should().BeTrue();
27-
postbackTransaction.CreatedDateTime .Should().Be(DateTimeOffset.Parse("2016-08-31T21:22:56.2467731+02:00"));
28-
postbackTransaction.CanceledDateTime .Should().BeNull();
29-
(postbackTransaction.Context is null) .Should().BeTrue();
30-
postbackTransaction.Checksum .Should().Be("cdc09eee2ed6df2846dcc193aedfef59f2834f8d");
31-
32-
var signers = postbackTransaction.Signers;
33-
signers.Should().HaveCount(1);
34-
35-
var signer = signers.Single();
36-
signer.Id .Should().Be("fa95495d-6c59-48e0-962a-a4552f8d6b85");
37-
signer.Expires .Should().BeNull();
38-
signer.Email .Should().Be("user@example.com");
39-
signer.SendSignRequest .Should().BeTrue();
40-
signer.SendSignConfirmation.Should().BeNull();
41-
signer.SignRequestMessage .Should().Be("Hello, could you please sign this document? Best regards, John Doe");
42-
signer.DaysToRemind .Should().Be(15);
43-
signer.Language .Should().Be("en-US");
44-
signer.ScribbleName .Should().Be("John Doe");
45-
signer.ScribbleNameFixed .Should().BeFalse();
46-
signer.Reference .Should().Be("Client #123");
47-
signer.ReturnUrl .Should().Be("https://signhost.com");
48-
signer.RejectReason .Should().BeNull();
49-
signer.SignUrl .Should().Be("https://view.signhost.com/sign/d3c93bd6-f1ce-48e7-8c9c-c2babfdd4034");
50-
(signer.Context is null) .Should().BeTrue();
51-
52-
var verifications = signer.Verifications;
53-
verifications.Should().HaveCount(3);
54-
55-
var phoneNumberVerification = verifications[0] as PhoneNumberVerification;
56-
phoneNumberVerification .Should().NotBeNull();
57-
phoneNumberVerification.Number.Should().Be("+31612345678");
58-
59-
var scribbleVerification = verifications[1] as ScribbleVerification;
60-
scribbleVerification .Should().NotBeNull();
61-
scribbleVerification.RequireHandsignature.Should().BeFalse();
62-
scribbleVerification.ScribbleNameFixed .Should().BeFalse();
63-
scribbleVerification.ScribbleName .Should().Be("John Doe");
64-
65-
var ipAddressVerification = verifications[2] as IPAddressVerification;
66-
ipAddressVerification .Should().NotBeNull();
67-
ipAddressVerification.IPAddress.Should().Be("1.2.3.4");
68-
69-
var activities = signer.Activities;
70-
activities.Should().HaveCount(3);
71-
72-
var openedActivity = activities[0];
73-
openedActivity.Id .Should().Be("bcba44a9-c201-4494-9920-2c1f7baebcf0");
74-
openedActivity.Code .Should().Be(ActivityType.Opened);
75-
openedActivity.Info .Should().BeNull();
76-
openedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2016-06-15T23:33:04.1965465+02:00"));
77-
78-
var documentOpenedActivity = activities[1];
79-
documentOpenedActivity.Id .Should().Be("7aacf96a-5c2f-475d-98a5-726e41bfc5d3");
80-
documentOpenedActivity.Code .Should().Be(ActivityType.DocumentOpened);
81-
documentOpenedActivity.Info .Should().Be("file1");
82-
documentOpenedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2020-01-30T16:31:05.6679583+01:00"));
83-
84-
var signedActivity = activities[2];
85-
signedActivity.Id .Should().Be("de94cf6e-e1a3-4c33-93bf-2013b036daaf");
86-
signedActivity.Code .Should().Be(ActivityType.Signed);
87-
signedActivity.Info .Should().BeNull();
88-
signedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2016-06-15T23:38:04.1965465+02:00"));
89-
90-
var receivers = postbackTransaction.Receivers;
91-
receivers.Should().HaveCount(1);
92-
93-
var receiver = receivers.Single();
94-
receiver.Name .Should().Be("John Doe");
95-
receiver.Email .Should().Be("user@example.com");
96-
receiver.Language .Should().Be("en-US");
97-
receiver.Message .Should().Be("Hello, please find enclosed the digital signed document. Best regards, John Doe");
98-
receiver.Reference .Should().BeNull();
99-
receiver.Activities .Should().BeNull();
100-
(receiver.Context is null).Should().BeTrue();
101-
102-
var files = postbackTransaction.Files;
103-
files.Should().HaveCount(1);
104-
105-
var file = files["file1"];
106-
file.DisplayName.Should().Be("Sample File");
107-
108-
var links = file.Links;
109-
links.Should().HaveCount(1);
110-
111-
var link = links.Single();
112-
link.Rel .Should().Be("file");
113-
link.Type.Should().Be("application/pdf");
114-
link.Link.Should().Be("https://api.signhost.com/api/transaction/b10ae331-af78-4e79-a39e-5b64693b6b68/file/file1");
115-
}
16+
string json = JsonResources.MockPostbackValid;
17+
var postbackTransaction = JsonSerializer.Deserialize<PostbackTransaction>(json, SignhostJsonSerializerOptions.Default);
18+
19+
postbackTransaction.Id .Should().Be("b10ae331-af78-4e79-a39e-5b64693b6b68");
20+
postbackTransaction.Status .Should().Be(TransactionStatus.InProgress);
21+
postbackTransaction.Seal .Should().BeTrue();
22+
postbackTransaction.Reference .Should().Be("Contract #123");
23+
postbackTransaction.PostbackUrl .Should().Be("https://example.com/postback.php");
24+
postbackTransaction.SignRequestMode .Should().Be(2);
25+
postbackTransaction.DaysToExpire .Should().Be(30);
26+
postbackTransaction.SendEmailNotifications.Should().BeTrue();
27+
postbackTransaction.CreatedDateTime .Should().Be(DateTimeOffset.Parse("2016-08-31T21:22:56.2467731+02:00"));
28+
postbackTransaction.CanceledDateTime .Should().BeNull();
29+
(postbackTransaction.Context is null) .Should().BeTrue();
30+
postbackTransaction.Checksum .Should().Be("cdc09eee2ed6df2846dcc193aedfef59f2834f8d");
31+
32+
var signers = postbackTransaction.Signers;
33+
signers.Should().HaveCount(1);
34+
35+
var signer = signers.Single();
36+
signer.Id .Should().Be("fa95495d-6c59-48e0-962a-a4552f8d6b85");
37+
signer.Expires .Should().BeNull();
38+
signer.Email .Should().Be("user@example.com");
39+
signer.SendSignRequest .Should().BeTrue();
40+
signer.SendSignConfirmation.Should().BeNull();
41+
signer.SignRequestMessage .Should().Be("Hello, could you please sign this document? Best regards, John Doe");
42+
signer.DaysToRemind .Should().Be(15);
43+
signer.Language .Should().Be("en-US");
44+
signer.ScribbleName .Should().Be("John Doe");
45+
signer.ScribbleNameFixed .Should().BeFalse();
46+
signer.Reference .Should().Be("Client #123");
47+
signer.ReturnUrl .Should().Be("https://signhost.com");
48+
signer.RejectReason .Should().BeNull();
49+
signer.SignUrl .Should().Be("https://view.signhost.com/sign/d3c93bd6-f1ce-48e7-8c9c-c2babfdd4034");
50+
(signer.Context is null) .Should().BeTrue();
51+
52+
var verifications = signer.Verifications;
53+
verifications.Should().HaveCount(3);
54+
55+
var phoneNumberVerification = verifications[0] as PhoneNumberVerification;
56+
phoneNumberVerification .Should().NotBeNull();
57+
phoneNumberVerification.Number.Should().Be("+31612345678");
58+
59+
var scribbleVerification = verifications[1] as ScribbleVerification;
60+
scribbleVerification .Should().NotBeNull();
61+
scribbleVerification.RequireHandsignature.Should().BeFalse();
62+
scribbleVerification.ScribbleNameFixed .Should().BeFalse();
63+
scribbleVerification.ScribbleName .Should().Be("John Doe");
64+
65+
var ipAddressVerification = verifications[2] as IPAddressVerification;
66+
ipAddressVerification .Should().NotBeNull();
67+
ipAddressVerification.IPAddress.Should().Be("1.2.3.4");
68+
69+
var activities = signer.Activities;
70+
activities.Should().HaveCount(3);
71+
72+
var openedActivity = activities[0];
73+
openedActivity.Id .Should().Be("bcba44a9-c201-4494-9920-2c1f7baebcf0");
74+
openedActivity.Code .Should().Be(ActivityType.Opened);
75+
openedActivity.Info .Should().BeNull();
76+
openedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2016-06-15T23:33:04.1965465+02:00"));
77+
78+
var documentOpenedActivity = activities[1];
79+
documentOpenedActivity.Id .Should().Be("7aacf96a-5c2f-475d-98a5-726e41bfc5d3");
80+
documentOpenedActivity.Code .Should().Be(ActivityType.DocumentOpened);
81+
documentOpenedActivity.Info .Should().Be("file1");
82+
documentOpenedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2020-01-30T16:31:05.6679583+01:00"));
83+
84+
var signedActivity = activities[2];
85+
signedActivity.Id .Should().Be("de94cf6e-e1a3-4c33-93bf-2013b036daaf");
86+
signedActivity.Code .Should().Be(ActivityType.Signed);
87+
signedActivity.Info .Should().BeNull();
88+
signedActivity.CreatedDateTime.Should().Be(DateTimeOffset.Parse("2016-06-15T23:38:04.1965465+02:00"));
89+
90+
var receivers = postbackTransaction.Receivers;
91+
receivers.Should().HaveCount(1);
92+
93+
var receiver = receivers.Single();
94+
receiver.Name .Should().Be("John Doe");
95+
receiver.Email .Should().Be("user@example.com");
96+
receiver.Language .Should().Be("en-US");
97+
receiver.Message .Should().Be("Hello, please find enclosed the digital signed document. Best regards, John Doe");
98+
receiver.Reference .Should().BeNull();
99+
receiver.Activities .Should().BeNull();
100+
(receiver.Context is null).Should().BeTrue();
101+
102+
var files = postbackTransaction.Files;
103+
files.Should().HaveCount(1);
104+
105+
var file = files["file1"];
106+
file.DisplayName.Should().Be("Sample File");
107+
108+
var links = file.Links;
109+
links.Should().HaveCount(1);
110+
111+
var link = links.Single();
112+
link.Rel .Should().Be("file");
113+
link.Type.Should().Be("application/pdf");
114+
link.Link.Should().Be("https://api.signhost.com/api/transaction/b10ae331-af78-4e79-a39e-5b64693b6b68/file/file1");
116115
}
117116
}

0 commit comments

Comments
 (0)