From 99e4f96f632f7d85f038e23a99158c43d85d0724 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Wed, 27 Nov 2024 13:07:26 +0100 Subject: [PATCH] Updated some testing code --- .../Comparers/SystemTextJsonComparer.cs | 3 ++- CryptoExchange.Net/Testing/TestHelpers.cs | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs index 7c44f4e..871127a 100644 --- a/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs +++ b/CryptoExchange.Net/Testing/Comparers/SystemTextJsonComparer.cs @@ -375,7 +375,8 @@ namespace CryptoExchange.Net.Testing.Comparers } else if (objectValue is DateTime time) { - if (time != DateTimeConverter.ParseFromString(jsonValue.Value()!)) + var jsonStr = jsonValue.Value()!; + if (!string.IsNullOrEmpty(jsonStr) && time != DateTimeConverter.ParseFromString(jsonStr)) throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {time}"); } else if (objectValue is bool bl) diff --git a/CryptoExchange.Net/Testing/TestHelpers.cs b/CryptoExchange.Net/Testing/TestHelpers.cs index 59d1e7a..0f91d44 100644 --- a/CryptoExchange.Net/Testing/TestHelpers.cs +++ b/CryptoExchange.Net/Testing/TestHelpers.cs @@ -173,17 +173,20 @@ namespace CryptoExchange.Net.Testing foreach (var clientInterface in clientInterfaces) { - var implementation = assembly.GetTypes().Single(t => clientInterface.IsAssignableFrom(t) && t != clientInterface); - int methods = 0; - foreach (var method in implementation.GetMethods().Where(m => implementationTypes.IsAssignableFrom(m.ReturnType))) + var implementations = assembly.GetTypes().Where(t => clientInterface.IsAssignableFrom(t) && t != clientInterface); + foreach (var implementation in implementations) { - var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); - if (interfaceMethod == null) - throw new Exception($"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); - methods++; - } + int methods = 0; + foreach (var method in implementation.GetMethods().Where(m => implementationTypes.IsAssignableFrom(m.ReturnType))) + { + var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); + if (interfaceMethod == null) + throw new Exception($"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); + methods++; + } - Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); + Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); + } } } }