コード例 #1
0
        public void PatchesNonErrorMessagesToWrappedImplementation(BrokerageMessageType type)
        {
            var wrapped = new Mock <IBrokerageMessageHandler>();

            wrapped.Setup(bmh => bmh.Handle(It.IsAny <BrokerageMessageEvent>())).Verifiable();

            var downgrader = new DowngradeErrorCodeToWarningBrokerageMessageHandler(wrapped.Object, new[] { "code" });
            var message    = new BrokerageMessageEvent(type, "code", "message");

            downgrader.Handle(message);

            wrapped.Verify(bmh => bmh.Handle(message), Times.Once);
        }
コード例 #2
0
        public void ErrorTest()
        {
            string actual = null;

            // subscribe to invalid symbol
            const string expected = "[\"BTC-LTC\"]";

            _wss.Setup(w => w.Send(It.IsAny <string>())).Callback <string>(c => actual = c);

            _unit.Subscribe(new[] { Symbol.Create("BTCLTC", SecurityType.Crypto, Market.GDAX) });

            StringAssert.Contains(expected, actual);

            BrokerageMessageType messageType = 0;

            _unit.Message += (sender, e) => { messageType = e.Type; };
            const string json = "{\"type\":\"error\",\"message\":\"Failed to subscribe\",\"reason\":\"Invalid product ID provided\"}";

            _unit.OnMessage(_unit, GDAXTestsHelpers.GetArgs(json));

            Assert.AreEqual(BrokerageMessageType.Warning, messageType);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the BrokerageMessageEvent class
 /// </summary>
 /// <param name="type">The type of brokerage message</param>
 /// <param name="code">The brokerage specific code</param>
 /// <param name="message">The message text received from the brokerage</param>
 public BrokerageMessageEvent(BrokerageMessageType type, string code, string message)
 {
     Type = type;
     Code = code;
     Message = message;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the BrokerageMessageEvent class
 /// </summary>
 /// <param name="type">The type of brokerage message</param>
 /// <param name="code">The brokerage specific code</param>
 /// <param name="message">The message text received from the brokerage</param>
 public BrokerageMessageEvent(BrokerageMessageType type, int code, string message)
 {
     Type = type;
     Code = code.ToString();
     Message = message;
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the BrokerageMessageEvent class
 /// </summary>
 /// <param name="type">The type of brokerage message</param>
 /// <param name="code">The brokerage specific code</param>
 /// <param name="message">The message text received from the brokerage</param>
 public BrokerageMessageEvent(BrokerageMessageType type, int code, string message)
 {
     Type    = type;
     Code    = code;
     Message = message;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the BrokerageMessageEvent class
 /// </summary>
 /// <param name="type">The type of brokerage message</param>
 /// <param name="code">The brokerage specific code</param>
 /// <param name="message">The message text received from the brokerage</param>
 public BrokerageMessageEvent(BrokerageMessageType type, int code, string message)
 {
     Type    = type;
     Code    = code.ToStringInvariant();
     Message = message;
 }