public async Task ValidStockInfo()
        {
            var response = await stockService.GetStockInfo("aapl.us");

            Assert.True(response.Success);
            Assert.Equal("aapl.us", response.StockInfo.Symbol.ToLower());
        }
Пример #2
0
        public void Consume()
        {
            EnsureConnection();
            Console.WriteLine("Listening to messages...");

            var consumer = new EventingBasicConsumer(_channel);

            consumer.Received += async(model, ea) =>
            {
                var body      = ea.Body.ToArray();
                var stockCode = Encoding.UTF8.GetString(body);
                Console.WriteLine("Received request for stock {0}", stockCode);

                var stockInfo = await _stocksService.GetStockInfo(stockCode);

                _stockMessageSender.Send(stockInfo);
            };

            _channel.BasicConsume(queue: AppConstants.STOCK_MESSAGE_REQUEST_Q,
                                  autoAck: true,
                                  consumer: consumer);
        }