Beispiel #1
0
 private void App_OnStartup(object sender, StartupEventArgs e)
 {
     var mainWindow = new MainWindow();
     var stockPresenter = new StockPresenter(mainWindow, new StockData(new SqlDataProvider<StockModel>()));
     Debug.WriteLine(stockPresenter);
     mainWindow.Show();
 }
 public void Constructor_NullStockView_ShouldThrowException()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var stockPresenter = new StockPresenter(null, null);
     });
 }
        public void FindClickAction_EmptySymbol_ShouldNotCallStockData_ShouldNotCallDisplayData()
        {
            //Moq
            //Arrange
            var stockView = new Mock<IStockView>();
            var stockData = new Mock<IStockData>();
            var stockPresenter = new StockPresenter(stockView.Object, stockData.Object);

            //Act
            stockView.Raise(x => x.FindClickAction += null, default(EventArgs));

            //Assert
            stockData.Verify(x => x.Find(It.IsAny<string>()), Times.Never);
            stockView.Verify(x => x.DisplayStockData(It.IsAny<string>()), Times.Never);
        }
        public void FindClickAction_Symbol_ShouldCallStockData_ShouldCallDisplayData()
        {
            //Moq
            //Arrange
            var stockView = new Mock<IStockView>();
            var symbol = "Sample";

            stockView.SetupGet(x => x.StockSymbol).Returns(symbol);

            var stockData = new Mock<IStockData>();
            stockData.Setup(x => x.Find(It.IsAny<string>())).Returns(new StockModel());

            var stockPresenter = new StockPresenter(stockView.Object, stockData.Object);

            //Act
            stockView.Raise(x => x.FindClickAction += null, default(EventArgs));

            //Assert
            stockData.Verify(x => x.Find(""), Times.Once);
            stockView.Verify(x => x.DisplayStockData(It.IsAny<string>()), Times.Once);
        }