-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
AddressTests.cs
94 lines (69 loc) · 2.52 KB
/
AddressTests.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
89
90
91
92
93
94
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Coinbase.Models;
using FluentAssertions;
using NUnit.Framework;
using static Coinbase.Tests.Examples;
namespace Coinbase.Tests.Endpoints
{
public class AddressTests : OAuthServerTest
{
[Test]
public async Task can_list_addresses()
{
SetupServerPagedResponse(PaginationJson, $"{Address1},{Address2}");
var accounts = await client.Addresses.ListAddressesAsync("ffff");
var truth = new PagedResponse<AddressEntity>
{
Pagination = PaginationModel,
Data = new[] { Address1Model, Address2Model }
};
truth.Should().BeEquivalentTo(accounts);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/ffff/addresses")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task get_an_address()
{
SetupServerSingleResponse(Address1);
var account = await client.Addresses.GetAddressAsync("ffff", Address1Model.Id);
var truth = new Response<AddressEntity>
{
Data = Address1Model
};
truth.Should().BeEquivalentTo(account);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/ffff/addresses/{Address1Model.Id}")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_list_address_transactions()
{
SetupServerPagedResponse(PaginationJson, $"{Transaction1}");
var txs = await client.Addresses.ListAddressTransactionsAsync("fff", "uuu");
var truth = new PagedResponse<Transaction>
{
Pagination = PaginationModel,
Data = new []{Transaction1Model}
};
truth.Should().BeEquivalentTo(txs);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/addresses/uuu/transactions")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_create_address()
{
SetupServerSingleResponse(Address1WithName("ddd"));
var create = new CreateAddress { Name = "ddd"};
var add = await client.Addresses.CreateAddressAsync("fff", create);
var truth = new Response<AddressEntity>
{
Data = Address1Model
};
truth.Data.Name = "ddd";
truth.Should().BeEquivalentTo(add);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/fff/addresses")
.WithVerb(HttpMethod.Post);
}
}
}