mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-04-12 16:13:12 +00:00
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
65 lines
2.3 KiB
C#
65 lines
2.3 KiB
C#
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);
|
|
}
|
|
}
|