public void ShouldAskForQuoteData(string symbol) { // Arrange _rabbitMeService.OnQuoteDataReceived -= new NotifyCallerDelegate(OnQuoteReceived); _rabbitMeService.OnQuoteDataReceived += new NotifyCallerDelegate(OnQuoteReceived); // Act _rabbitMeService.AskForQuote(symbol); }
public async Task <IActionResult> SendRequest(MessageDto msg) { var user = await _identityService.GetUserAsync(this.User.FindFirst(ClaimTypes.NameIdentifier).Value); if (msg.Message.ToLowerInvariant().StartsWith("/stock=")) { var symbol = msg.Message.Split('=')[1]; _rabbitMqService.OnQuoteDataReceived -= new NotifyCallerDelegate(OnQuoteReceived); _rabbitMqService.OnQuoteDataReceived += new NotifyCallerDelegate(OnQuoteReceived); _rabbitMqService.AskForQuote(symbol); await _hubContext.Clients.All.SendAsync("ReceiveChatMessage", "Bot", $"You have asked for the following stock: {symbol} ...please wait a moment while getting your quote"); } else { await _conversationService.SaveConversationMessage(new MessageDto { User = user.UserName, Message = msg.Message }); await _hubContext.Clients.All.SendAsync("ReceiveChatMessage", user.UserName, msg.Message); } return(Ok()); }