public static string CreateSubscribeErrorMessage(AccountSubscriptionType subscriptionType) { var message = @"{ ""action"":""sub"", ""code"":2002, ""ch"":""" + subscriptionType.ToTopicId() + @"#btcusdt"", ""message"":""invalid.auth.state"" }"; return(message); }
public static string ToTopicId(this AccountSubscriptionType subscriptionType) { return(subscriptionType switch { AccountSubscriptionType.Orders => "orders", AccountSubscriptionType.TradeDetails => "trade.clearing", AccountSubscriptionType.AccountUpdates => "accounts.update", _ => throw new ArgumentOutOfRangeException( nameof(subscriptionType), subscriptionType, $"Unable to translate {nameof(subscriptionType)} value '{subscriptionType}' to topic ID!") });
public void HandleResponse_SubscribeErrorMessage_StreamUpdated(AccountSubscriptionType subscriptionType) { var triggered = false; var client = InitializeAccountClient(); client.Streams.AccountErrorMessageStream.Subscribe( msg => { triggered = true; // Assert Assert.NotNull(msg); }); var message = HuobiAccountMessagesFactory.CreateSubscribeErrorMessage(subscriptionType); // Act TriggerMessageReceive(message); // Assert VerifyMessageNotUnhandled(); Assert.True(triggered); }
public AccountSubscribeRequest(string symbol, AccountSubscriptionType subscriptionType) : base("sub", FormatChannel(symbol, subscriptionType)) { }
private static string FormatChannel(string symbol, AccountSubscriptionType subscriptionType) { return($"{subscriptionType.ToTopicId()}#{symbol}"); }