diff --git a/CryptoExchange.Net/Converters/SystemTextJson/NumberStringConverter.cs b/CryptoExchange.Net/Converters/SystemTextJson/NumberStringConverter.cs index a45014aa..7beafd9d 100644 --- a/CryptoExchange.Net/Converters/SystemTextJson/NumberStringConverter.cs +++ b/CryptoExchange.Net/Converters/SystemTextJson/NumberStringConverter.cs @@ -17,7 +17,12 @@ public class NumberStringConverter : JsonConverter return null; if (reader.TokenType == JsonTokenType.Number) - return reader.GetInt64().ToString(); + { + if (reader.TryGetInt64(out var value)) + return value.ToString(); + + return reader.GetDecimal().ToString(); + } return reader.GetString(); } diff --git a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs index 465e8c4d..9544da4e 100644 --- a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs +++ b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs @@ -357,6 +357,13 @@ private static void CheckValues(string method, string property, Type propertyTyp if (time != DateTimeConverter.ParseFromString(jsonValue.Value()!)) throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {time}"); } + else if (objectValue is bool bl) + { + if (bl && jsonValue.Value() != "1") + throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {bl}"); + if (!bl && jsonValue.Value() != "0") + throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {bl}"); + } else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true) { // TODO enum comparing diff --git a/CryptoExchange.Net/Testing/TestHelpers.cs b/CryptoExchange.Net/Testing/TestHelpers.cs index ba699d1e..044fa288 100644 --- a/CryptoExchange.Net/Testing/TestHelpers.cs +++ b/CryptoExchange.Net/Testing/TestHelpers.cs @@ -121,8 +121,8 @@ public static void CheckSignature( if (disableOrdering) client.OrderParameters = false; - var uriParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InUri ? client.CreateParameterDictionary(parameters) : new Dictionary(); - var bodyParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InBody ? client.CreateParameterDictionary(parameters) : new Dictionary(); + var uriParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InUri ? client.CreateParameterDictionary(parameters) : null; + var bodyParams = client.ParameterPositions[method] == HttpMethodParameterPosition.InBody ? client.CreateParameterDictionary(parameters) : null; var headers = new Dictionary();