コード例 #1
0
        public async Task HandleCombinedStreamData()
        {
            var message = $"{{\"stream\":\"{_streamName}\",\"data\":{_message}}}";

            var stream = new BinanceWebSocketStream(DefaultWebSocketClientTest.CreateWebSocketClient(message))
            {
                Uri = _uri // NOTE: Processing of combined stream data is not dependant upon URI.
            };

            var isMessageEventReceived = false;

            using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1)))
            {
                stream.Message += (s, e) =>
                {
                    isMessageEventReceived = e.Subject == _streamName && e.Json == _message;
                };

                Assert.False(isMessageEventReceived);

                await stream.StreamAsync(cts.Token);

                Assert.True(isMessageEventReceived);
            }
        }
コード例 #2
0
 public WebSocketStreamTest()
 {
     _uri     = new Uri(BinanceWebSocketStream.BaseUri);
     _subject = _uri.AbsoluteUri;
     _stream  = new WebSocketStream(DefaultWebSocketClientTest.CreateWebSocketClient(_message));
 }
コード例 #3
0
 public BinanceWebSocketStreamTest()
 {
     _uri    = BinanceWebSocketStream.CreateUri(_streamName);
     _stream = new BinanceWebSocketStream(DefaultWebSocketClientTest.CreateWebSocketClient(_message));
 }