private int callBrokerBot()
        {
            BrokerBot bot = new BrokerBot();
            Messages  botMessage;
            string    stockCode    = _message.Substring(_message.IndexOf("=") + 1).Trim();
            string    jsonResponse = bot.getStockQuote(stockCode);
            var       jsontxt      = JToken.Parse(jsonResponse);

            bool result;

            bool.TryParse(((JValue)jsontxt["Result"]).ToString(), out result);

            botMessage            = new Messages();
            botMessage.CreateDate = DateTime.Now.ToString();
            botMessage.UserName   = "******";

            if (result)
            {
                botMessage.Message = $" {stockCode.ToUpper()} quote is {((JValue)jsontxt["message"])?.ToString()} per share";
            }
            else
            {
                botMessage.Message = ((JValue)jsontxt["message"])?.ToString();
            }

            bootMessage = JsonConvert.SerializeObject(botMessage, Formatting.Indented);
            return(1);
        }
Beispiel #2
0
        public void getQuoteTest()
        {
            BrokerBot bot   = new BrokerBot();
            string    quote = bot.getStockQuote("aapl.us");

            Assert.IsTrue(!string.IsNullOrEmpty(quote));
        }