-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
UserTests.cs
88 lines (65 loc) · 2.18 KB
/
UserTests.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Net.Http;
using System.Threading.Tasks;
using Coinbase.Models;
using FluentAssertions;
using NUnit.Framework;
namespace Coinbase.Tests.Endpoints
{
public class UserTests : OAuthServerTest
{
[Test]
public async Task can_get_user()
{
SetupServerSingleResponse(Examples.User);
const string userId = "9da7a204-544e-5fd1-9a12-61176c5d4cd8";
var user = await client.Users.GetUserAsync(userId);
var truth = new Response<User>
{
Data = Examples.UserModel
};
user.Should().BeEquivalentTo(truth);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/users/{userId}")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_get_current_user()
{
SetupServerSingleResponse(Examples.User);
var user = await client.Users.GetCurrentUserAsync();
var truth = new Response<User>
{
Data = Examples.UserModel
};
user.Should().BeEquivalentTo(truth);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/user")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_get_auth_information()
{
SetupServerSingleResponse(Examples.Auth);
var user = await client.Users.GetAuthInfoAsync();
var truth = new Response<Auth>
{
Data = Examples.AuthModel
};
user.Should().BeEquivalentTo(truth);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/user/auth")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task update_user()
{
SetupServerSingleResponse(Examples.UserWithNameChange("bbb ccc"));
var user = await client.Users.UpdateUserAsync(new UserUpdate{ Name = "bbb ccc"});
var truth = new Response<User>
{
Data = Examples.UserModel
};
truth.Data.Name = "bbb ccc";
user.Should().BeEquivalentTo(truth);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/user")
.WithVerb(HttpMethod.Put);
}
}
}