public void AddStock(StockInputModel model)
        {
            var stock = model.AsStock();

            _fund.Add(stock);
            UpdateStocks();
        }
示例#2
0
        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> >()));
        }
示例#3
0
        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));
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }