1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-18 20:02:57 +00:00

Array comparison updates for unit tests

This commit is contained in:
JKorf
2024-06-26 15:13:21 +02:00
parent fcfeaf568f
commit 8a83cd2cb8
2 changed files with 30 additions and 17 deletions
@@ -26,8 +26,13 @@ namespace CryptoExchange.Net.Testing.Comparers
if (nestedJsonProperty != null)
{
var nested = nestedJsonProperty.Split('.');
foreach(var nest in nested)
jsonObject = jsonObject![nest];
foreach (var nest in nested)
{
if (int.TryParse(nest, out var index))
jsonObject = jsonObject![index];
else
jsonObject = jsonObject![nest];
}
}
if (userSingleArrayItem)
@@ -94,9 +99,9 @@ namespace CryptoExchange.Net.Testing.Comparers
continue;
int i = 0;
foreach (var item in jObj.Values())
foreach (var item in jObj.Children())
{
var arrayProp = resultProps.SingleOrDefault(p => p.Item2!.Index == i).p;
var arrayProp = resultProps.Where(p => p.Item2 != null).SingleOrDefault(p => p.Item2!.Index == i).p;
if (arrayProp != null)
CheckPropertyValue(method, item, arrayProp.GetValue(resultObj), arrayProp.PropertyType, arrayProp.Name, "Array index " + i, ignoreProperties!);
i++;
@@ -219,9 +224,9 @@ namespace CryptoExchange.Net.Testing.Comparers
continue;
int i = 0;
foreach (var item in jtoken.Values())
foreach (var item in jtoken.Children())
{
var arrayProp = resultProps.SingleOrDefault(p => p.Item2!.Index == i).p;
var arrayProp = resultProps.Where(p => p.Item2 != null).SingleOrDefault(p => p.Item2!.Index == i).p;
if (arrayProp != null)
CheckPropertyValue(method, item, arrayProp.GetValue(resultObj), propertyType, arrayProp.Name, "Array index " + i, ignoreProperties);