Exemple #1
0
        public void AddStockSuccess()
        {
            var stockTicker = new Mock <IStockTicker>();

            stockTicker.Setup(st => st.TryAddStock(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Stock());

            var hub = new StockQuoteHub(stockTicker.Object);

            var result = hub.AddStock("jon", "msft");

            stockTicker.VerifyAll();
            Assert.AreEqual("MSFT added to your stock list", result);
        }
Exemple #2
0
        public void AddStockFailure()
        {
            var stockTicker = new Mock <IStockTicker>();

            stockTicker.Setup(st => st.TryAddStock(It.IsAny <string>(), It.IsAny <string>()))
            .Returns <Stock>(null);

            var hub = new StockQuoteHub(stockTicker.Object);

            var result = hub.AddStock("jon", "blah");

            stockTicker.VerifyAll();
            Assert.AreEqual("Error: Could not add BLAH", result);
        }
Exemple #3
0
        public void GetMyStocksBadInput()
        {
            var stockTicker = new Mock <IStockTicker>();

            stockTicker.Setup(st => st.GetStocksByUser(It.IsAny <string>()))
            .Returns(new List <Stock>()
            {
                new Stock()
            });

            var hub = new StockQuoteHub(stockTicker.Object);

            var result = hub.GetMyStocks("");

            stockTicker.VerifyNoOtherCalls();
            Assert.IsNull(result);
        }
Exemple #4
0
        public void GetMyStocksSuccess()
        {
            var stockTicker = new Mock <IStockTicker>();

            stockTicker.Setup(st => st.GetStocksByUser(It.IsAny <string>()))
            .Returns(new List <Stock>()
            {
                new Stock()
            });

            var hub = new StockQuoteHub(stockTicker.Object);

            var result = hub.GetMyStocks("jon");

            stockTicker.VerifyAll();
            Assert.AreEqual(1, result.Count);
        }
Exemple #5
0
        public void AddStockBadInput()
        {
            var stockTicker = new Mock <IStockTicker>();

            stockTicker.Setup(st => st.TryAddStock(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Stock());

            var hub = new StockQuoteHub(stockTicker.Object);

            var result = hub.AddStock("", "msft");

            stockTicker.VerifyNoOtherCalls();
            Assert.AreEqual("No user provided!", result);

            result = hub.AddStock("jon", "");

            stockTicker.VerifyNoOtherCalls();
            Assert.AreEqual("No stock symbol provided!", result);
        }