-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
SellTest.cs
101 lines (77 loc) · 2.58 KB
/
SellTest.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 SellTests : OAuthServerTest
{
[Test]
public async Task can_list()
{
SetupServerPagedResponse(PaginationJson, $"{Sell1}");
var r = await client.Sells.ListSellsAsync("fff");
var truth = new PagedResponse<Sell>
{
Pagination = PaginationModel,
Data = new[]
{
Sell1Model
}
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/fff/sells")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_get()
{
SetupServerSingleResponse(Sell1);
var r = await client.Sells.GetSellAsync("fff", "uuu");
var truth = new Response<Sell>
{
Data = Sell1Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/sells/uuu")
.WithVerb(HttpMethod.Get);
}
[Test]
public async Task can_place_sellorder()
{
SetupServerSingleResponse(Sell2);
var create = new PlaceSell
{
Amount = 10m,
Currency = "BTC",
PaymentMethod = "B28EB04F-BD70-4308-90A1-96065283A001"
};
var r = await client.Sells.PlaceSellOrderAsync("fff", create );
var truth = new Response<Sell>
{
Data = Sell2Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveRequestBody(
@"{""amount"":10.0,""currency"":""BTC"",""payment_method"":""B28EB04F-BD70-4308-90A1-96065283A001"",""agree_btc_amount_varies"":false,""commit"":false,""quote"":false}");
server.ShouldHaveExactCall($"https://api.coinbase.com/v2/accounts/fff/sells")
.WithVerb(HttpMethod.Post);
}
[Test]
public async Task can_commit()
{
SetupServerSingleResponse(Sell2);
var r = await client.Sells.CommitSellAsync("fff", "uuu");
var truth = new Response<Sell>
{
Data = Sell2Model
};
truth.Should().BeEquivalentTo(r);
server.ShouldHaveExactCall("https://api.coinbase.com/v2/accounts/fff/sells/uuu/commit")
.WithVerb(HttpMethod.Post);
}
}
}