Skip to content

Commit

Permalink
Migrate unit tests to use https://github.com/VerifyTests/Verify
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed Aug 9, 2020
1 parent 18900fa commit 75ecbae
Show file tree
Hide file tree
Showing 93 changed files with 2,388 additions and 490 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ paket.lock
.paket/paket.exe
/Source/.paket/**
__test
**.received.**

# User-specific files
*.suo
Expand Down
22 changes: 21 additions & 1 deletion Source/Coinbase.Pro/CoinbaseProClient.Deposits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ Task<List<Deposit>> ListDeposits(string profileId = null,
int? limit = null, DateTimeOffset? before = null, DateTimeOffset? after = null,
CancellationToken cancellationToken = default);


/// <summary>
/// You can generate an address for crypto deposits. See the Coinbase Accounts section for information on how to retrieve your coinbase account ID.
/// </summary>
/// <returns></returns>
Task<GeneratedDepositCryptoAddress> GenerateCryptoDepositAddress(
string coinbaseAccountId,
CancellationToken cancellationToken = default);

}

public partial class CoinbaseProClient : IDepositsEndpoint
Expand Down Expand Up @@ -101,7 +110,7 @@ Task<Deposit> IDepositsEndpoint.GetDeposit(string transferId,
{
return this.TransfersEndpoint
.WithClient(this)
.SetQueryParam("transfer_id", transferId)
.AppendPathSegment(transferId)
.GetJsonAsync<Deposit>(cancellationToken);
}

Expand All @@ -118,5 +127,16 @@ Task<List<Deposit>> IDepositsEndpoint.ListDeposits(string profileId,
.SetQueryParam("limit", limit)
.GetJsonAsync<List<Deposit>>(cancellationToken);
}

Task<GeneratedDepositCryptoAddress> IDepositsEndpoint.GenerateCryptoDepositAddress(
string coinbaseAccountId,
CancellationToken cancellationToken)
{
return this.CoinbaseAccountsEndpoint
.WithClient(this)
.AppendPathSegments(coinbaseAccountId, "addresses")
.PostJsonAsync(null, cancellationToken)
.ReceiveJson<GeneratedDepositCryptoAddress>();
}
}
}
52 changes: 49 additions & 3 deletions Source/Coinbase.Pro/Models/Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public partial class WithdrawalDetails : Json
public string CoinbasePaymentMethodId { get; set; }
}

public partial class Deposit
public partial class Deposit : Json
{
[JsonProperty("id")]
public string Id { get; set; }
Expand Down Expand Up @@ -788,7 +788,7 @@ public partial class Deposit
public DepositDetails Details { get; set; }
}

public partial class DepositDetails
public partial class DepositDetails : Json
{
[JsonProperty("crypto_address")]
public string CryptoAddress { get; set; }
Expand All @@ -812,7 +812,53 @@ public partial class DepositDetails
public string CryptoTransactionHash { get; set; }
}

public partial class Conversion



public partial class GeneratedDepositCryptoAddress : Json
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("address")]
public string Address { get; set; }

[JsonProperty("destination_tag")]
public string DestinationTag { get; set; }

[JsonProperty("address_info")]
public GeneratedDepositCryptoAddressAddressInfo AddressInfo { get; set; }

[JsonProperty("created_at")]
public DateTimeOffset? CreatedAt { get; set; }

[JsonProperty("updated_at")]
public DateTimeOffset? UpdatedAt { get; set; }

[JsonProperty("network")]
public string Network { get; set; }

[JsonProperty("resource")]
public string Resource { get; set; }

[JsonProperty("deposit_uri")]
public string DepositUri { get; set; }

[JsonProperty("exchange_deposit_address")]
public bool ExchangeDepositAddress { get; set; }
}

public partial class GeneratedDepositCryptoAddressAddressInfo : Json
{
[JsonProperty("address")]
public string Address { get; set; }

[JsonProperty("destination_tag")]
public string DestinationTag { get; set; }
}


public partial class Conversion : Json
{
[JsonProperty("id")]
public string Id { get; set; }
Expand Down
10 changes: 9 additions & 1 deletion Source/Coinbase.Tests/Coinbase.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<OutputType>Library</OutputType>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
Expand All @@ -25,10 +25,18 @@
</PackageReference>
<PackageReference Include="NunitXml.TestLogger" Version="2.1.62" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Verify.NUnit" Version="6.7.0" />
<PackageReference Include="WebSocket4Net" Version="0.15.2" />
<PackageReference Include="Z.ExtensionMethods.WithTwoNamespace" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Coinbase.Pro\Coinbase.Pro.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="**\*.server.*">
<ParentExtension>$(ProjectExt.Replace('proj', ''))</ParentExtension>
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<DependentUpon>%(ParentFile)%(ParentExtension)</DependentUpon>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "71452118-efc7-4cc4-8780-a5e22d4baa53",
"currency": "BTC",
"balance": "0.0000000000000000",
"available": "0.0000000000000000",
"hold": "0.0000000000000000",
"profile_id": "75da88c5-05bf-4f54-bc85-5c775bd68254"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
id: Guid_1,
currency: 'BTC',
profile_id: Guid_2
}
19 changes: 12 additions & 7 deletions Source/Coinbase.Tests/EndpointTests/AccountsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AccountsTest : TestWithAuth
[Test]
public async Task get_all_accounts()
{
server.RespondWith(Examples.AccountListJson);
server.RespondWithJsonTestFile();

var r = await client.Accounts.GetAllAccountsAsync();

Expand All @@ -20,12 +20,14 @@ public async Task get_all_accounts()
a.Id.Should().Be("71452118-efc7-4cc4-8780-a5e22d4baa53");

server.ShouldHaveCalledSomePathAndQuery("/accounts");

await Verify(r);
}

[Test]
public async Task can_get_account()
{
server.RespondWith(Examples.Account1Json);
server.RespondWithJsonTestFile();

var r = await client.Accounts.GetAccountAsync("fff");

Expand All @@ -35,29 +37,30 @@ public async Task can_get_account()
r.Id.Should().Be("71452118-efc7-4cc4-8780-a5e22d4baa53");

server.ShouldHaveCalledSomePathAndQuery("/accounts/fff");

await Verify(r);
}

[Test]
public async Task get_history()
{
server.RespondWith(Examples.AccountHistoryJson);
server.RespondWithJsonTestFile();

var r = await client.Accounts.GetAccountHistoryAsync("fff");

r.Dump();

//r.Before.Should().Be(9);
var a = r.Data.First();
a.Id.Should().Be("44512583");
a.Amount.Should().Be(1000.0000000000000000m);

server.ShouldHaveCalledSomePathAndQuery("/accounts/fff/ledger");

await Verify(r);
}

[Test]
public async Task get_hold()
{
server.RespondWith(Examples.AccountHoldJson);
server.RespondWithJsonTestFile();

var r = await client.Accounts.GetAccountHoldAsync("fff");

Expand All @@ -67,6 +70,8 @@ public async Task get_hold()
h.AccountId.Should().Be("e0b3f39a-183d-453e-b754-0c13e5bab0b3");

server.ShouldHaveCalledSomePathAndQuery("/accounts/fff/holds");

await Verify(r);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"id": "71452118-efc7-4cc4-8780-a5e22d4baa53",
"currency": "BTC",
"balance": "0.0000000000000000",
"available": "0.0000000000000000",
"hold": "0.0000000000000000",
"profile_id": "75da88c5-05bf-4f54-bc85-5c775bd68254"
},
{
"id": "e316cb9a-0808-4fd7-8914-97829c1925de",
"currency": "USD",
"balance": "80.2301373066930000",
"available": "79.2266348066930000",
"hold": "1.0035025000000000",
"profile_id": "75da88c5-05bf-4f54-bc85-5c775bd68254"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
id: Guid_1,
currency: 'BTC',
profile_id: Guid_2
},
{
id: Guid_3,
currency: 'USD',
balance: 80.2301373066930000,
available: 79.2266348066930000,
hold: 1.0035025000000000,
profile_id: Guid_2
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"created_at": "2018-10-25T18:33:58.614187Z",
"id": 44512583,
"amount": "1000.0000000000000000",
"balance": "1000.0000000000000000",
"type": "transfer",
"details": {
"transfer_id": "ffff2937-ffff-ffff-ffff-44ae9640ffff",
"transfer_type": "deposit"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
Data: [
{
id: '44512583',
created_at: DateTimeOffset_1,
amount: 1000.0000000000000000,
balance: 1000.0000000000000000,
type: 'transfer',
details: {
transfer_id: Guid_1,
transfer_type: 'deposit'
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"id": "82dcd140-c3c7-4507-8de4-2c529cd1a28f",
"account_id": "e0b3f39a-183d-453e-b754-0c13e5bab0b3",
"created_at": "2014-11-06T10:34:47.123456Z",
"updated_at": "2014-11-06T10:40:47.123456Z",
"amount": "4.23",
"type": "order",
"ref": "0a205de4-dd35-4370-a285-fe8fc375a273",
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
Data: [
{
id: Guid_1,
account_id: Guid_2,
created_at: DateTimeOffset_1,
updated_at: DateTimeOffset_2,
amount: '4.23',
type: 'order',
ref: Guid_3
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
id: Guid_1,
name: 'ETH Wallet',
currency: 'ETH',
type: 'wallet',
active: true
},
{
id: Guid_2,
name: 'USD Wallet',
currency: 'USD',
type: 'fiat',
active: true,
wire_deposit_information: {
account_number: '0199003122',
routing_number: '026013356',
bank_name: 'Metropolitan Commercial Bank',
bank_address: '99 Park Ave 4th Fl New York, NY 10016',
bank_country: {
code: 'US',
name: 'United States'
},
account_name: 'Coinbase, Inc',
account_address: '548 Market Street, #23008, San Francisco, CA 94104',
reference: 'BAOCAEUX'
}
},
{
id: Guid_3,
name: 'BTC Wallet',
currency: 'BTC',
type: 'wallet',
primary: true,
active: true
},
{
id: Guid_4,
name: 'EUR Wallet',
currency: 'EUR',
type: 'fiat',
active: true,
sepa_deposit_information: {
iban: 'EE957700771001355096',
swift: 'LHVBEE22',
bank_name: 'AS LHV Pank',
bank_address: 'Tartu mnt 2, 10145 Tallinn, Estonia',
bank_country_name: 'Estonia',
account_name: 'Coinbase UK, Ltd.',
account_address: '9th Floor, 107 Cheapside, London, EC2V 6DN, United Kingdom',
reference: 'CBAEUXOVFXOXYX'
}
}
]
Loading

0 comments on commit 75ecbae

Please sign in to comment.