mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-11 16:32:57 +00:00
Socket routing improvements, unit test cleanup (#276)
Updated WebSocket message routing improving performance for scenarios with multiple different subscriptions and topics Added AddCommaSeparated helper for Enum value arrays to ParameterCollection Improved EnumConverter performance and removed string allocation for happy path Fixed CreateParamString extension method for ArrayParametersSerialization.Json Fixed Shared GetOrderBookOptions and GetRecentTradeOptions base validations not being called
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
|
||||
namespace CryptoExchange.Net.UnitTests.Implementations
|
||||
{
|
||||
internal class TestEnvironment : TradeEnvironment
|
||||
{
|
||||
public string RestClientAddress { get; }
|
||||
public string SocketClientAddress { get; }
|
||||
|
||||
internal TestEnvironment(
|
||||
string name,
|
||||
string restAddress,
|
||||
string streamAddress) :
|
||||
base(name)
|
||||
{
|
||||
RestClientAddress = restAddress;
|
||||
SocketClientAddress = streamAddress;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
public TestEnvironment() : base(TradeEnvironmentNames.Live)
|
||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Get the environment by name
|
||||
/// </summary>
|
||||
public static TestEnvironment? GetEnvironmentByName(string? name)
|
||||
=> name switch
|
||||
{
|
||||
TradeEnvironmentNames.Live => Live,
|
||||
"" => Live,
|
||||
null => Live,
|
||||
_ => default
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Available environment names
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] All => [Live.Name];
|
||||
|
||||
/// <summary>
|
||||
/// Live environment
|
||||
/// </summary>
|
||||
public static TestEnvironment Live { get; }
|
||||
= new TestEnvironment(TradeEnvironmentNames.Live,
|
||||
"https://localhost",
|
||||
"wss://localhost");
|
||||
|
||||
/// <summary>
|
||||
/// Create a custom environment
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="spotRestAddress"></param>
|
||||
/// <param name="spotSocketStreamsAddress"></param>
|
||||
/// <returns></returns>
|
||||
public static TestEnvironment CreateCustom(
|
||||
string name,
|
||||
string spotRestAddress,
|
||||
string spotSocketStreamsAddress)
|
||||
=> new TestEnvironment(name, spotRestAddress, spotSocketStreamsAddress);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user