示例#1
0
        public void NotAddingAnythingProducesEmptyResult()
        {
            var sut = new Fund(_stockNameProviderMock.Object, _stockWeightProviderMock.Object);

            var result = sut.GetStocks().FirstOrDefault();

            Assert.IsNull(result);
        }
        public FundViewModel(Fund fund)
        {
            var temporaryCollection = fund.GetStocks().Select(stock => new StockViewModel(stock)).ToList();

            Stocks = new ListCollectionView(temporaryCollection);

            _fund         = fund;
            GetStocksFunc = fund.GetStocks;
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
        private void UpdateStocks()
        {
            var list = _fund.GetStocks().Select(stock => new StockViewModel(stock)).ToList();

            Stocks = new ListCollectionView(list);
        }