示例#1
0
        public void JoeAndJackDaltonGetNotifiedAboutPriceChange()
        {
            // Arrange
            Investor investorJoe  = new Investor("Joe Dalton");
            Investor investorJack = new Investor("Jack Dalton");

            var appleStock = new Stock("Apple", new decimal(100));

            appleStock.AddInvestor(investorJoe);
            appleStock.AddInvestor(investorJack);

            // Act
            appleStock.UpdatePrice(new decimal(101));

            // Assert
            Assert.Equal("Apple stock price just changed to 101", investorJoe.LastStockChangeInfo);
            Assert.Equal("Apple stock price just changed to 101", investorJack.LastStockChangeInfo);
        }
示例#2
0
        public void JackDaltonNotInterestedInStocks()
        {
            // Arrange
            Investor investorJoe  = new Investor("Joe Dalton");
            Investor investorJack = new Investor("Jack Dalton");

            var appleStock = new Stock("Apple", new decimal(100));

            appleStock.AddInvestor(investorJoe);
            appleStock.AddInvestor(investorJack);

            // (Jack not interested in)
            appleStock.RemoveInvestor(investorJack);

            // Act
            appleStock.UpdatePrice(new decimal(101));

            // Assert
            Assert.Equal("Apple stock price just changed to 101", investorJoe.LastStockChangeInfo);
            Assert.Equal("Not last stock info", investorJack.LastStockChangeInfo);
        }
 public void RemoveInvestor(Investor investor) => this.Investors.Remove(investor);
 public void AddInvestor(Investor investor) => this.Investors.Add(investor);