-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from mwarzybok-sumoheavy/feature/SP-874
SP-874 Support "errors" array
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 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
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,33 @@ | ||
// Copyright (c) 2019 BitPay. | ||
// All rights reserved. | ||
|
||
using System.Net; | ||
using System.Net.Http; | ||
|
||
using BitPay.Clients; | ||
using BitPay.Exceptions; | ||
|
||
using Xunit; | ||
|
||
namespace BitPayUnitTest.Clients | ||
{ | ||
public class HttpResponseParserTest | ||
{ | ||
[Fact] | ||
public void it_should_throws_bitpay_api_exception_for_response_with_errors() | ||
{ | ||
HttpResponseMessage responseMessage = new HttpResponseMessage | ||
{ | ||
StatusCode = HttpStatusCode.OK, | ||
Content = new StringContent( | ||
"{\"errors\":[{\"error\":\"Missing required parameter.\",\"param\":\"price\"},{\"error\":\"Missing required parameter.\",\"param\":\"currency\"}]}"), | ||
RequestMessage = new HttpRequestMessage(HttpMethod.Post, "any") | ||
}; | ||
|
||
var exception = | ||
Assert.ThrowsAsync<BitPayApiException>(() => HttpResponseParser.ResponseToJsonString(responseMessage)) | ||
.Result; | ||
Assert.Equal("Missing required parameter price. Missing required parameter currency.", exception.Message); | ||
} | ||
} | ||
} |