コード例 #1
0
        protected KrakenClientTests(ITestOutputHelper output, KrakenFixture fixture)
        {
            Client = new KrakenClient(ApiKey, PrivateKey)
            {
                // If the API key has two factor password enabled, set the line below to return it.
                //GetTwoFactorPassword = () => Task.FromResult("<INSERT_PASSWORD>")

                ErrorsAsExceptions   = true,
                WarningsAsExceptions = true,

                // Log request and response for each test.
                InterceptRequest = async req =>
                {
                    output.WriteLine("REQUEST");
                    output.WriteLine(req.HttpRequest.ToString());
                    string content = await req.HttpRequest.Content.ReadAsStringAsync();

                    if (!string.IsNullOrWhiteSpace(content))
                    {
                        output.WriteLine(content);
                    }

                    // Wait if we have hit the API rate limit.
                    RateLimiter limiter = req.HttpRequest.RequestUri.OriginalString.Contains("/private/")
                        ? fixture.PrivateApiRateLimiter
                        : fixture.PublicApiRateLimiter;

                    await limiter.WaitAccess(req.ApiCallCost);
                },
                InterceptResponse = async res =>
                {
                    output.WriteLine("");
                    output.WriteLine("RESPONSE");
                    output.WriteLine(res.HttpResponse.ToString());
                    string content = await res.HttpResponse.Content.ReadAsStringAsync();

                    output.WriteLine(JToken.Parse(content).ToString(Formatting.Indented));
                }
            };
        }
コード例 #2
0
 public KrakenClientPrivateApiTests(ITestOutputHelper output, KrakenFixture fixture)
     : base(output, fixture)
 {
 }