-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
WithdrawlTests.cs
101 lines (77 loc) · 2.67 KB
/
WithdrawlTests.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
95
96
97
98
99
100
101
using System.Linq;
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 WithdrawlTests : OAuthServerTest
{
[Test]
public async Task can_list()
{
SetupServerPagedResponse(PaginationJson, $"{Withdrawal1}");
var r = await client.Withdrawals.ListWithdrawalsAsync("fff");
var truth = new PagedResponse<Withdrawal>
{
Pagination = PaginationModel,
Data = new[]
{
Withdrawal1Model
}
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/fff/withdrawals")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_get()
{
SetupServerSingleResponse(Withdrawal1);
var r = await client.Withdrawals.GetWithdrawalAsync("fff", "uuu");
var truth = new Response<Withdrawal>
{
Data = Withdrawal1Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/withdrawals/uuu")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_withdrawal()
{
SetupServerSingleResponse(Withdrawal1);
var create = new WithdrawalFunds
{
Amount = 10.0m,
Currency = "USD",
PaymentMethod = "B28EB04F-BD70-4308-90A1-96065283A001"
};
var r = await client.Withdrawals.WithdrawalFundsAsync("fff", create );
var truth = new Response<Withdrawal>
{
Data = Withdrawal1Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveRequestBody(
@"{""amount"":10.0,""currency"":""USD"",""payment_method"":""B28EB04F-BD70-4308-90A1-96065283A001"",""commit"":false}");
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/withdrawals")
.WithVerb(HttpMethod.Post);
}
[Test]
public async Task can_commit()
{
SetupServerSingleResponse(Withdrawal1);
var r = await client.Withdrawals.CommitWithdrawalAsync("fff", "uuu");
var truth = new Response<Withdrawal>
{
Data = Withdrawal1Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/fff/withdrawals/uuu/commit")
.WithVerb(HttpMethod.Post);
}
}
}