From 9df960361a520e8cc6fa5846149e4120141c0683 Mon Sep 17 00:00:00 2001 From: JKorf Date: Sun, 6 Sep 2026 20:27:37 +0200 Subject: [PATCH] wip --- CryptoExchange.Net/Testing/TestHelpers.cs | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/CryptoExchange.Net/Testing/TestHelpers.cs b/CryptoExchange.Net/Testing/TestHelpers.cs index 4970fffb..08ba7052 100644 --- a/CryptoExchange.Net/Testing/TestHelpers.cs +++ b/CryptoExchange.Net/Testing/TestHelpers.cs @@ -194,7 +194,7 @@ namespace CryptoExchange.Net.Testing public static (Type[] missingOptions, Type[] missingInterfaces) ValidateSharedApi(T sharedApi) where T : ISharedApi { - var implementedCapabilities = sharedApi + var allCapabilities = sharedApi .GetType() .GetInterfaces() .Where(x => @@ -206,6 +206,12 @@ namespace CryptoExchange.Net.Testing && typeof(ISharedApiCapability).IsAssignableFrom(x)) .ToArray(); + var implementedCapabilities = allCapabilities + .Where(candidate => !allCapabilities.Any(other => + candidate != other && + candidate.IsAssignableFrom(other))) + .ToArray(); + var declaredCapabilities = sharedApi.Capabilities .Select(x => x.CapabilityType) .ToArray(); @@ -222,5 +228,30 @@ namespace CryptoExchange.Net.Testing return (missingOptions.ToArray(), missingInterfaces.ToArray()); } + + /// + /// Validates that the shared API implementation doesn't have any unsupported capabilities declared + /// + public static CapabilityOptions[] ValidateUnsupportedCapabilities(T sharedApi) + where T : ISharedApi + { + var implementedCapabilities = sharedApi + .GetType() + .GetInterfaces() + .Where(x => + x != typeof(T) + && x != typeof(ISharedApiCapability) + && x != typeof(ISharedRest) + && x != typeof(ISharedSocket) + && x != typeof(ISharedSubscription) + && typeof(ISharedApiCapability).IsAssignableFrom(x)) + .ToArray(); + + var declaredCapabilities = sharedApi.Capabilities + .Where(x => !x.Supported) + .ToArray(); + + return declaredCapabilities; + } } }