mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-19 09:31:43 +00:00
Fix test validation failing with empty body string
This commit is contained in:
@@ -168,12 +168,18 @@ namespace CryptoExchange.Net.Testing
|
||||
{
|
||||
// Validate request body
|
||||
Dictionary<string, object> bodyParameters;
|
||||
if (result.RequestBody!.StartsWith("{") || result.RequestBody.StartsWith("["))
|
||||
if (string.IsNullOrEmpty(result.RequestBody))
|
||||
{
|
||||
bodyParameters = new Dictionary<string, object>();
|
||||
}
|
||||
else if (result.RequestBody!.StartsWith("{") || result.RequestBody.StartsWith("["))
|
||||
{
|
||||
// Json
|
||||
bodyParameters = JsonSerializer.Deserialize<Dictionary<string, object>>(result.RequestBody!)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Form data
|
||||
var splitKvp = result.RequestBody.Split('&');
|
||||
bodyParameters = splitKvp.Select(x => x.Split('=')).ToDictionary(x => x[0], x => (object)x[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user