diff --git a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs
index 63dd22b7..77cef363 100644
--- a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs
+++ b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs
@@ -395,9 +395,9 @@ namespace CryptoExchange.Net.Testing.Comparers
}
else if (objectValue is bool bl)
{
- if (bl && (stringValue != "1" && stringValue != "true" && stringValue != "True"))
+ if (bl && (stringValue != "1" && stringValue != "true" && stringValue != "True" && stringValue != "yes" && stringValue != "YES"))
throw new Exception($"{method}: {property} not equal: {stringValue} vs {bl}");
- if (!bl && (stringValue != "0" && stringValue != "-1" && stringValue != "false" && stringValue != "False"))
+ if (!bl && (stringValue != "0" && stringValue != "-1" && stringValue != "false" && stringValue != "False" && stringValue != "no" && stringValue != "NO"))
throw new Exception($"{method}: {property} not equal: {stringValue} vs {bl}");
}
else if (propertyType.IsEnum || Nullable.GetUnderlyingType(propertyType)?.IsEnum == true)
diff --git a/CryptoExchange.Net/Testing/RestRequestValidator.cs b/CryptoExchange.Net/Testing/RestRequestValidator.cs
index 4328bb34..8d71bd95 100644
--- a/CryptoExchange.Net/Testing/RestRequestValidator.cs
+++ b/CryptoExchange.Net/Testing/RestRequestValidator.cs
@@ -57,6 +57,7 @@ namespace CryptoExchange.Net.Testing
/// Method name for looking up json test values
/// Use nested json property for compare
/// Ignore certain properties
+ /// Ignore certain parameter validation
/// Use the first item of an json array response
/// Whether to skip the response model validation
///
@@ -66,9 +67,10 @@ namespace CryptoExchange.Net.Testing
string name,
string? nestedJsonProperty = null,
List? ignoreProperties = null,
+ List? ignoreParamValidation = null,
bool useSingleArrayItem = false,
bool skipResponseValidation = false)
- => ValidateAsync(methodInvoke, name, nestedJsonProperty, ignoreProperties, useSingleArrayItem, skipResponseValidation);
+ => ValidateAsync(methodInvoke, name, nestedJsonProperty, ignoreProperties, ignoreParamValidation, useSingleArrayItem, skipResponseValidation);
///
/// Validate a request
@@ -79,6 +81,7 @@ namespace CryptoExchange.Net.Testing
/// Method name for looking up json test values
/// Use nested json property for compare
/// Ignore certain properties
+ /// Ignore certain parameter validation
/// Use the first item of an json array response
/// Whether to skip the response model validation
///
@@ -88,6 +91,7 @@ namespace CryptoExchange.Net.Testing
string name,
string? nestedJsonProperty = null,
List? ignoreProperties = null,
+ List? ignoreParamValidation = null,
bool useSingleArrayItem = false,
bool skipResponseValidation = false) where TActualResponse : TResponse
{
@@ -156,7 +160,7 @@ namespace CryptoExchange.Net.Testing
? urlParametersString.Split('&').ToDictionary(x => x.Split('=')[0], x => (object)x.Split('=')[1])
: new());
- CompareParameters(expectedUriParams, urlParameters);
+ CompareParameters(expectedUriParams, urlParameters, ignoreParamValidation);
}
if (expectedBodyParams != null)
@@ -173,7 +177,7 @@ namespace CryptoExchange.Net.Testing
bodyParameters = splitKvp.Select(x => x.Split('=')).ToDictionary(x => x[0], x => (object)x[1]);
}
- CompareParameters(expectedBodyParams, bodyParameters);
+ CompareParameters(expectedBodyParams, bodyParameters, ignoreParamValidation);
}
if (!skipResponseValidation)
@@ -186,13 +190,16 @@ namespace CryptoExchange.Net.Testing
Trace.Listeners.Remove(listener);
}
- private void CompareParameters(Dictionary expectedUrlParameters, Dictionary parameters)
+ private void CompareParameters(Dictionary expectedUrlParameters, Dictionary parameters, List? ignoreParamValidation)
{
if (expectedUrlParameters.Count > parameters.Count)
throw new Exception($"Url parameters count not matched. Expected: {expectedUrlParameters.Count}, Actual: {parameters.Count}");
foreach (var kvp in expectedUrlParameters)
{
+ if (ignoreParamValidation != null && ignoreParamValidation.Contains(kvp.Key))
+ continue;
+
if (!parameters.TryGetValue(kvp.Key, out var value))
throw new Exception($"Url parameter {kvp.Key} not found in actual parameters");
@@ -206,11 +213,14 @@ namespace CryptoExchange.Net.Testing
///
/// Method invocation
/// Method name for looking up json test values
+ /// Ignore certain parameter validation
///
///
public async Task ValidateAsync(
Func> methodInvoke,
- string name)
+ string name,
+ List? ignoreParamValidation = null
+ )
{
var listener = new EnumValueTraceListener();
Trace.Listeners.Add(listener);
@@ -278,7 +288,7 @@ namespace CryptoExchange.Net.Testing
? urlParametersString.Split('&').ToDictionary(x => x.Split('=')[0], x => (object)x.Split('=')[1])
: new());
- CompareParameters(expectedUriParams, urlParameters);
+ CompareParameters(expectedUriParams, urlParameters, ignoreParamValidation);
}
if (expectedBodyParams != null)
@@ -295,7 +305,7 @@ namespace CryptoExchange.Net.Testing
bodyParameters = splitKvp.Select(x => x.Split('=')).ToDictionary(x => x[0], x => (object)x[1]);
}
- CompareParameters(expectedBodyParams, bodyParameters);
+ CompareParameters(expectedBodyParams, bodyParameters, ignoreParamValidation);
}
Trace.Listeners.Remove(listener);