コード例 #1
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);
        }
コード例 #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);
        }
コード例 #3
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);
        }