diff --git a/CryptoExchange.Net/Testing/TestHelpers.cs b/CryptoExchange.Net/Testing/TestHelpers.cs
index 532dbbe..3c5720f 100644
--- a/CryptoExchange.Net/Testing/TestHelpers.cs
+++ b/CryptoExchange.Net/Testing/TestHelpers.cs
@@ -150,9 +150,9 @@ namespace CryptoExchange.Net.Testing
///
///
///
- public static void CheckForMissingRestInterfaces()
+ public static void CheckForMissingRestInterfaces(string[]? excludeInterfaces = null)
{
- CheckForMissingInterfaces(typeof(TClient), typeof(Task));
+ CheckForMissingInterfaces(typeof(TClient), typeof(Task), excludeInterfaces);
}
///
@@ -160,26 +160,32 @@ namespace CryptoExchange.Net.Testing
///
///
///
- public static void CheckForMissingSocketInterfaces()
+ public static void CheckForMissingSocketInterfaces(string[]? excludeInterfaces = null)
{
- CheckForMissingInterfaces(typeof(TClient), typeof(Task>));
+ CheckForMissingInterfaces(typeof(TClient), typeof(Task>), excludeInterfaces);
}
- private static void CheckForMissingInterfaces(Type clientType, Type implementationTypes)
+ private static void CheckForMissingInterfaces(Type clientType, Type implementationTypes, string[]? excludeInterfaces = null)
{
var assembly = Assembly.GetAssembly(clientType);
var interfaceType = clientType.GetInterface("I" + clientType.Name);
- var clientInterfaces = assembly!.GetTypes().Where(t => t.Name.StartsWith("I" + clientType.Name) && !t.Name.EndsWith("Shared"));
+ var clientInterfaces = assembly!.GetTypes()
+ .Where(t => t.Name.StartsWith("I" + clientType.Name)
+ && !t.Name.EndsWith("Shared")
+ && (excludeInterfaces?.Contains(t.Name) != true));
foreach (var clientInterface in clientInterfaces)
{
- var implementations = assembly.GetTypes().Where(t => clientInterface.IsAssignableFrom(t) && t != clientInterface);
+ var implementations = assembly.GetTypes().Where(t => clientInterface.IsAssignableFrom(t) && !t.IsInterface && t != clientInterface);
foreach (var implementation in implementations)
{
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()) ?? throw new Exception($"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}");
+ var interfaceMethod =
+ clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray())
+ ?? clientInterface.GetInterfaces().Select(x => x.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray())).FirstOrDefault()
+ ?? throw new Exception($"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}");
methods++;
}