public void AddStock(StockInputModel model) { var stock = model.AsStock(); _fund.Add(stock); UpdateStocks(); }
public void AddingAStockResultsInWeightProviderBeingCalled() { _stockWeightProviderMock.Setup(x => x.UpdateStockWeights(It.IsAny <IEnumerable <Stock> >())); var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object); var stockMock = new Mock <Stock>(MockBehavior.Strict, 3.0m, 4); sut.Add(stockMock.Object); _stockWeightProviderMock.Verify(x => x.UpdateStockWeights(It.IsAny <IEnumerable <Stock> >())); }
public void AddngAStockResultsInNameProviderBeingCalled() { _stockNameProviderMock.Setup(x => x.CreateNewStockName(It.IsAny <Stock>())); var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object); var stockMock = new Mock <Stock>(MockBehavior.Strict, 1.0m, 2); sut.Add(stockMock.Object); _stockNameProviderMock.Verify(x => x.CreateNewStockName(stockMock.Object)); }
public void AddShouldAddStockToFund() { var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object); var stockMock = new Mock <Stock>(MockBehavior.Strict, 0.0m, 0); sut.Add(stockMock.Object); var result = sut.GetStocks().FirstOrDefault(); Assert.AreEqual(stockMock.Object, result); }
public void AddingOneStockTwiceProducesAListWithADuplicate() { var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object); var stock = new Mock <Stock>(MockBehavior.Strict, 3.0m, 3).Object; var list = new List <Stock> { stock, stock }; list.ForEach(item => sut.Add(item)); var result = sut.GetStocks(); CollectionAssert.AreEquivalent(result, list); }
public void GetStocksReturnsStocks() { var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object); var list = new List <Stock> { new Mock <Stock>(MockBehavior.Strict, 1.0m, 1).Object, new Mock <Stock>(MockBehavior.Strict, 2.0m, 2).Object }; list.ForEach(item => sut.Add(item)); var result = sut.GetStocks(); CollectionAssert.AreEquivalent(result, list); }