-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathChangeUserDetails.cs
More file actions
78 lines (65 loc) · 2.83 KB
/
ChangeUserDetails.cs
File metadata and controls
78 lines (65 loc) · 2.83 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
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SignNow.Net.Model.Requests;
namespace SignNow.Net.Examples
{
public partial class UserExamples
{
[TestMethod]
public async Task ChangeUserDetailsAsync()
{
// Get current user details
var currentUser = await testContext.Users
.GetCurrentUserAsync()
.ConfigureAwait(false);
Console.WriteLine("Current user is: '{0}' '{1}'", currentUser.FirstName, currentUser.LastName);
// Update user details
var update = new UpdateUserOptions
{
FirstName = "signNow",
LastName = currentUser.LastName + "Updated",
OldPassword = credentials.Password,
Password = credentials.Password,
LogOutAll = false
};
var updateUserDetails = await testContext.Users
.UpdateUserAsync(update)
.ConfigureAwait(false);
// get updated user details
var updatedUser = await testContext.Users
.GetCurrentUserAsync()
.ConfigureAwait(false);
Console.WriteLine("Updated user is: '{0}' '{1}'", updatedUser.FirstName, updatedUser.LastName);
// check if user details were updated
Assert.AreEqual(currentUser.FirstName, updateUserDetails.FirstName);
Assert.AreNotEqual(currentUser.LastName, updateUserDetails.LastName);
Assert.AreEqual(currentUser.LastName + "Updated", updateUserDetails.LastName);
// Revert user details back
var revert = new UpdateUserOptions
{
FirstName = currentUser.FirstName,
LastName = currentUser.LastName,
OldPassword = credentials.Password,
Password = credentials.Password,
LogOutAll = false
};
var revertedUser = await testContext.Users
.UpdateUserAsync(revert)
.ConfigureAwait(false);
// get last user details
var lastUserInfo = await testContext.Users
.GetCurrentUserAsync()
.ConfigureAwait(false);
Console.WriteLine("Reverted user is: '{0}' '{1}'", lastUserInfo.FirstName, lastUserInfo.LastName);
// check if user details were reverted
Assert.AreEqual(currentUser.FirstName, lastUserInfo.FirstName);
Assert.AreEqual(currentUser.LastName, lastUserInfo.LastName);
Assert.AreEqual(currentUser.LastName, revertedUser.LastName);
// send user password reset email
await testContext.Users
.SendPasswordResetLinkAsync(currentUser.Email)
.ConfigureAwait(false);
}
}
}