示例#1
0
        public async Task SubscribeToTickerChannel(string productId)
        {
            var spy = new ReceivedMessageSpy(_testOutput);

            await RecordMessages(r => r.SubscribeToTickerChannel(spy.ReceiveMessage, productId));

            spy.ReceivedMessages.ShouldNotBeEmpty();
            var actualMessages = spy.ReceivedMessages.OfType <TickerMessage>().ToList();

            actualMessages.ShouldNotBeEmpty();
            actualMessages.ShouldContain(m => m.ProductId == productId);
        }
示例#2
0
        public async Task SubscribeToTickerChannel()
        {
            var spy           = new ReceivedMessageSpy(_outputHelper);
            var webSocketMock = new Mock <IClientWebSocketFacade>();

            webSocketMock.SetupReceiveAsyncSequence()
            .Returns("TestData/message_ETH-EUR_ticker.json");

            await RecordMessages(apiBuilder => apiBuilder
                                 .ConfigureFeed(builder => builder.SubscribeToTickerChannel(spy.ReceiveMessage, "ETH-EUR")), webSocketMock.Object);

            webSocketMock.Verify(socket => socket.ConnectAsync(It.Is <Uri>(u => u == EndpointUriNames.WebsocketFeedUri), It.IsAny <CancellationToken>()), Times.Exactly(1));
            webSocketMock.Verify(socket => socket.SendAsync(It.Is <ReadOnlyMemory <byte> >(buffer => buffer.ContainsUtf8String("\"ticker\",\"product_ids\":[\"ETH-EUR\"]")), It.Is <WebSocketMessageType>(t => t == WebSocketMessageType.Text), It.Is <bool>(j => j), It.IsAny <CancellationToken>()), Times.Exactly(1));
            spy.ReceivedMessages.OfType <TickerMessage>().ShouldHaveSingleItem();
        }
示例#3
0
        public async Task SubscribeToLevel2Channel(string productId)
        {
            var spy = new ReceivedMessageSpy(_testOutput);

            await RecordMessages(r => r.SubscribeToLevel2Channel(spy.ReceiveMessage, spy.ReceiveMessage, productId));

            spy.ReceivedMessages.ShouldNotBeEmpty();

            var snapshotMessage = spy.ReceivedMessages.OfType <Level2SnapshotMessage>().ShouldHaveSingleItem();

            snapshotMessage.ShouldNotBeNull();
            snapshotMessage.ProductId.ShouldBe(productId);

            var updateMessages = spy.ReceivedMessages.OfType <Level2UpdateMessage>().ToList();

            updateMessages.ShouldNotBeEmpty();
            updateMessages.ShouldContain(m => m.ProductId == productId);
        }