1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-19 17:40:59 +00:00

Fix test validation failing with empty body string

This commit is contained in:
Jkorf
2026-10-19 08:39:18 +02:00
parent f079e6f0f4
commit 186f30d4b5
@@ -168,12 +168,18 @@ namespace CryptoExchange.Net.Testing
{ {
// Validate request body // Validate request body
Dictionary<string, object> bodyParameters; 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!)!; bodyParameters = JsonSerializer.Deserialize<Dictionary<string, object>>(result.RequestBody!)!;
} }
else else
{ {
// Form data
var splitKvp = result.RequestBody.Split('&'); var splitKvp = result.RequestBody.Split('&');
bodyParameters = splitKvp.Select(x => x.Split('=')).ToDictionary(x => x[0], x => (object)x[1]); bodyParameters = splitKvp.Select(x => x.Split('=')).ToDictionary(x => x[0], x => (object)x[1]);
} }