mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-14 15:11:44 +00:00
wip
This commit is contained in:
@@ -194,7 +194,7 @@ namespace CryptoExchange.Net.Testing
|
|||||||
public static (Type[] missingOptions, Type[] missingInterfaces) ValidateSharedApi<T>(T sharedApi)
|
public static (Type[] missingOptions, Type[] missingInterfaces) ValidateSharedApi<T>(T sharedApi)
|
||||||
where T : ISharedApi
|
where T : ISharedApi
|
||||||
{
|
{
|
||||||
var implementedCapabilities = sharedApi
|
var allCapabilities = sharedApi
|
||||||
.GetType()
|
.GetType()
|
||||||
.GetInterfaces()
|
.GetInterfaces()
|
||||||
.Where(x =>
|
.Where(x =>
|
||||||
@@ -206,6 +206,12 @@ namespace CryptoExchange.Net.Testing
|
|||||||
&& typeof(ISharedApiCapability).IsAssignableFrom(x))
|
&& typeof(ISharedApiCapability).IsAssignableFrom(x))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
var implementedCapabilities = allCapabilities
|
||||||
|
.Where(candidate => !allCapabilities.Any(other =>
|
||||||
|
candidate != other &&
|
||||||
|
candidate.IsAssignableFrom(other)))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
var declaredCapabilities = sharedApi.Capabilities
|
var declaredCapabilities = sharedApi.Capabilities
|
||||||
.Select(x => x.CapabilityType)
|
.Select(x => x.CapabilityType)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
@@ -222,5 +228,30 @@ namespace CryptoExchange.Net.Testing
|
|||||||
|
|
||||||
return (missingOptions.ToArray(), missingInterfaces.ToArray());
|
return (missingOptions.ToArray(), missingInterfaces.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates that the shared API implementation doesn't have any unsupported capabilities declared
|
||||||
|
/// </summary>
|
||||||
|
public static CapabilityOptions[] ValidateUnsupportedCapabilities<T>(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user