Exemple #1
0
 public void GuoteManagerCheckFail()
 {
     IQuoteManager q = new QuoteManager();
     Assert.IsFalse(q.startWatching("asdf"));
     Assert.IsTrue(q.startWatching("GOOG"));
 }
        /// <summary>
        /// Button event that adds an item to a Watchlist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddToWatchList_Click(object sender, EventArgs e)
        {
            bool success = false;
            IQuoteManager qm = new QuoteManager();
            string symbol = tbAddToWatchList.Text.Trim().ToUpper();
            string listName = radioLists.SelectedValue;

            if (symbol.Length > 0)
            {
                // If it is valid, add it to the list
                if (qm.startWatching(symbol))
                {
                    IWatchList wl = new WatchList();
                    success = wl.AddToList(new Symbol(symbol), listName);
                    if (success)
                    {
                        setStatus(String.Format("{0} added to list \"{1}.\"", symbol, listName), true);
                    }
                    else
                    {
                        setStatus(String.Format("{0} could not be added to \"{1}.\"", symbol, listName), false);
                    }
                    strategy.startWatching(symbol);
                    updateList(true);
                }
                else // If it's not, display invalid symbol message.
                {
                    setStatus("Invalid symbol.", false);
                }
            }
            else
            {
                setStatus("Stock symbol cannot be blank.", false);
            }
        }