public void Throws() { Assert.Throws <ArgumentNullException>("symbol", () => _client.Subscribe((string)null)); Assert.Throws <ArgumentNullException>("symbol", () => _client.Subscribe(string.Empty)); Assert.Throws <ArgumentNullException>("symbol", () => _client.Unsubscribe((string)null)); Assert.Throws <ArgumentNullException>("symbol", () => _client.Unsubscribe(string.Empty)); }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="callback"></param> /// <param name="symbols"></param> public static ITradeClient Subscribe(this ITradeClient client, Action <TradeEventArgs> callback, params string[] symbols) { Throw.IfNull(client, nameof(client)); Throw.IfNull(symbols, nameof(symbols)); if (callback == null && !symbols.Any()) { throw new ArgumentException($"{nameof(Subscribe)}: At least one symbol is required.", nameof(symbols)); } foreach (var symbol in symbols) { client.Subscribe(symbol, callback); } return(client); }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> public static ITradeClient Subscribe(this ITradeClient client, string symbol) => client.Subscribe(symbol, null);