public void Buy_Stock_If_Invalid_Stock_Throws_An_Error() { ArgumentException ex = Assert.Throws <ArgumentException>(() => { _stockMarketService.BuyStock("FantasticBeer", 0.75, 2); }); Assert.Equal("FantasticBeer is not a tradable stock.", ex.Message); }
public void Buy_Stock_Add_Trade() { //Arrange var mockRepository = new Mock <ITrade>(); mockRepository.Setup(x => x.AddTrade(It.IsAny <Trade>())); var tradeService = new StockMarketService(mockRepository.Object, DataToTest.Stocks()); //Act tradeService.BuyStock(DataToTest.Tea.Symbol, 0.75, 2); //Assert mockRepository.Verify(x => x.AddTrade(It.IsAny <Trade>())); }