-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
621ac68
commit 63d88b7
Showing
32 changed files
with
411 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
GDAXClient.Specs/JsonFixtures/Deposits/CoinbaseDepositResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
GDAXClient.Specs/JsonFixtures/Products/ProductStatsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace GDAXClient.Specs.JsonFixtures.Products | ||
{ | ||
public static class ProductStatsFixture | ||
{ | ||
public static string Create() | ||
{ | ||
|
||
var json = @" | ||
{ | ||
'open': '34.19000000', | ||
'high': '95.70000000', | ||
'low': '7.06000000', | ||
'volume': '2.41000000' | ||
}"; | ||
|
||
return json; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
GDAXClient.Specs/JsonFixtures/Products/ProductTickerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace GDAXClient.Specs.JsonFixtures.Products | ||
{ | ||
public static class ProductTickerFixture | ||
{ | ||
public static string Create() | ||
{ | ||
var json = @" | ||
{ | ||
'trade_id': 4729088, | ||
'price': '333.99', | ||
'size': '0.193', | ||
'bid': '333.98', | ||
'ask': '333.99', | ||
'volume': '5957.11914015', | ||
'time': '2016-12-08T24:00:00Z' | ||
}"; | ||
|
||
return json; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
GDAXClient.Specs/JsonFixtures/Products/ProductsOrderBookResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace GDAXClient.Specs.JsonFixtures.Products | ||
{ | ||
public static class ProductsOrderBookResponseFixture | ||
{ | ||
public static string Create() | ||
{ | ||
var json = @" | ||
{ | ||
'sequence': '3', | ||
'bids': [ | ||
[200, 100, 3], | ||
], | ||
'ask': [ | ||
[200, 100, 3], | ||
] | ||
}"; | ||
|
||
return json; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
GDAXClient.Specs/JsonFixtures/Products/ProductsResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace GDAXClient.Specs.JsonFixtures.Products | ||
{ | ||
public static class ProductsResponseFixture | ||
{ | ||
public static string Create() | ||
{ | ||
var json = @" | ||
[ | ||
{ | ||
'id': 'BTC-USD', | ||
'base_currency': 'BTC', | ||
'quote_currency': 'USD', | ||
'base_min_size': '0.01', | ||
'base_max_size': '10000.00', | ||
'quote_increment': '0.01' | ||
} | ||
]"; | ||
|
||
return json; | ||
} | ||
} | ||
} |
150 changes: 150 additions & 0 deletions
150
GDAXClient.Specs/Services/Products/ProductsServiceSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
using GDAXClient.Authentication; | ||
using GDAXClient.HttpClient; | ||
using GDAXClient.Products; | ||
using GDAXClient.Services.HttpRequest; | ||
using GDAXClient.Services.Orders; | ||
using GDAXClient.Services.Products; | ||
using GDAXClient.Services.Products.Models; | ||
using GDAXClient.Services.Products.Models.Responses; | ||
using GDAXClient.Specs.JsonFixtures.Products; | ||
using Machine.Fakes; | ||
using Machine.Specifications; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace GDAXClient.Specs.Services.Payments | ||
{ | ||
[Subject("ProductsService")] | ||
public class ProductsServiceSpecs : WithSubject<ProductsService> | ||
{ | ||
static Authenticator authenticator; | ||
|
||
static IEnumerable<Product> products_result; | ||
|
||
static ProductsOrderBookResponse product_order_books_response; | ||
|
||
static ProductTicker product_ticker_result; | ||
|
||
static ProductStats product_stats_result; | ||
|
||
Establish context = () => | ||
authenticator = new Authenticator("apiKey", new string('2', 100), "passPhrase"); | ||
|
||
class when_getting_all_products | ||
{ | ||
Establish context = () => | ||
{ | ||
The<IHttpRequestMessageService>().WhenToldTo(p => p.CreateHttpRequestMessage(Param.IsAny<HttpMethod>(), Param.IsAny<Authenticator>(), Param.IsAny<string>(), Param.IsAny<string>())) | ||
.Return(new HttpRequestMessage()); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.SendASync(Param.IsAny<HttpRequestMessage>())) | ||
.Return(Task.FromResult(new HttpResponseMessage())); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.ReadAsStringAsync(Param.IsAny<HttpResponseMessage>())) | ||
.Return(Task.FromResult(ProductsResponseFixture.Create())); | ||
}; | ||
|
||
Because of = () => | ||
products_result = Subject.GetAllProductsAsync().Result; | ||
|
||
It should_have_correct_products_response_count = () => | ||
products_result.Count().ShouldEqual(1); | ||
|
||
It should_have_correct_products = () => | ||
{ | ||
products_result.First().Id.ShouldEqual("BTC-USD"); | ||
products_result.First().Base_currency.ShouldEqual("BTC"); | ||
products_result.First().Quote_currency.ShouldEqual("USD"); | ||
products_result.First().Base_min_size.ShouldEqual("0.01"); | ||
products_result.First().Base_max_size.ShouldEqual("10000.00"); | ||
products_result.First().Quote_increment.ShouldEqual("0.01"); | ||
}; | ||
} | ||
|
||
class when_getting_a_product_order_book | ||
{ | ||
Establish context = () => | ||
{ | ||
The<IHttpRequestMessageService>().WhenToldTo(p => p.CreateHttpRequestMessage(Param.IsAny<HttpMethod>(), Param.IsAny<Authenticator>(), Param.IsAny<string>(), Param.IsAny<string>())) | ||
.Return(new HttpRequestMessage()); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.SendASync(Param.IsAny<HttpRequestMessage>())) | ||
.Return(Task.FromResult(new HttpResponseMessage())); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.ReadAsStringAsync(Param.IsAny<HttpResponseMessage>())) | ||
.Return(Task.FromResult(ProductsOrderBookResponseFixture.Create())); | ||
}; | ||
|
||
Because of = () => | ||
product_order_books_response = Subject.GetProductOrderBookAsync(ProductType.BtcUsd).Result; | ||
|
||
It should_have_correct_product_order_book_response = () => | ||
{ | ||
product_order_books_response.Sequence.ShouldEqual(3M); | ||
product_order_books_response.Bids.SelectMany(p => p).ShouldContain(200); | ||
product_order_books_response.Bids.SelectMany(p => p).ShouldContain(100); | ||
product_order_books_response.Bids.SelectMany(p => p).ShouldContain(3); | ||
product_order_books_response.Ask.SelectMany(p => p).ShouldContain(200); | ||
product_order_books_response.Ask.SelectMany(p => p).ShouldContain(100); | ||
product_order_books_response.Ask.SelectMany(p => p).ShouldContain(3); | ||
}; | ||
} | ||
|
||
class when_getting_a_product_ticker | ||
{ | ||
Establish context = () => | ||
{ | ||
The<IHttpRequestMessageService>().WhenToldTo(p => p.CreateHttpRequestMessage(Param.IsAny<HttpMethod>(), Param.IsAny<Authenticator>(), Param.IsAny<string>(), Param.IsAny<string>())) | ||
.Return(new HttpRequestMessage()); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.SendASync(Param.IsAny<HttpRequestMessage>())) | ||
.Return(Task.FromResult(new HttpResponseMessage())); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.ReadAsStringAsync(Param.IsAny<HttpResponseMessage>())) | ||
.Return(Task.FromResult(ProductTickerFixture.Create())); | ||
}; | ||
|
||
Because of = () => | ||
product_ticker_result = Subject.GetProductTickerAsync(ProductType.BtcUsd).Result; | ||
|
||
It should_have_correct_product_ticker = () => | ||
{ | ||
product_ticker_result.Trade_id.ShouldEqual(4729088); | ||
product_ticker_result.Price.ShouldEqual(333.99M); | ||
product_ticker_result.Size.ShouldEqual(0.193M); | ||
product_ticker_result.Bid.ShouldEqual(333.98M); | ||
product_ticker_result.Ask.ShouldEqual(333.99M); | ||
product_ticker_result.Volume.ShouldEqual(5957.11914015M); | ||
product_ticker_result.Time.ShouldEqual(new System.DateTime(2016, 12, 9)); | ||
}; | ||
} | ||
|
||
class when_getting_product_stats | ||
{ | ||
Establish context = () => | ||
{ | ||
The<IHttpRequestMessageService>().WhenToldTo(p => p.CreateHttpRequestMessage(Param.IsAny<HttpMethod>(), Param.IsAny<Authenticator>(), Param.IsAny<string>(), Param.IsAny<string>())) | ||
.Return(new HttpRequestMessage()); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.SendASync(Param.IsAny<HttpRequestMessage>())) | ||
.Return(Task.FromResult(new HttpResponseMessage())); | ||
|
||
The<IHttpClient>().WhenToldTo(p => p.ReadAsStringAsync(Param.IsAny<HttpResponseMessage>())) | ||
.Return(Task.FromResult(ProductStatsFixture.Create())); | ||
}; | ||
|
||
Because of = () => | ||
product_stats_result = Subject.GetProductStatsAsync(ProductType.BtcUsd).Result; | ||
|
||
It should_have_correct_product_stats = () => | ||
{ | ||
product_stats_result.Open.ShouldEqual(34.19000000M); | ||
product_stats_result.High.ShouldEqual(95.70000000M); | ||
product_stats_result.Low.ShouldEqual(7.06000000M); | ||
product_stats_result.Volume.ShouldEqual(2.41000000M); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace GDAXClient.Services.Products | ||
{ | ||
public class Product | ||
{ | ||
public string Id { get; set; } | ||
|
||
public string Base_currency { get; set; } | ||
|
||
public string Quote_currency { get; set; } | ||
|
||
public string Base_min_size { get; set; } | ||
|
||
public string Base_max_size { get; set; } | ||
|
||
public string Quote_increment { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace GDAXClient.Services.Products.Models | ||
{ | ||
public class ProductStats | ||
{ | ||
public decimal Open { get; set; } | ||
|
||
public decimal High { get; set; } | ||
|
||
public decimal Low { get; set; } | ||
|
||
public decimal Volume { get; set; } | ||
} | ||
} |
Oops, something went wrong.