コード例 #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);
        }
コード例 #3
0
 public void RemoveInvestor(Investor investor) => this.Investors.Remove(investor);
コード例 #4
0
 public void AddInvestor(Investor investor) => this.Investors.Add(investor);