Esempio n. 1
0
 public void When_Detach_One_investor_Shoud_Notify_TheRest_When_Change_Price()
 {
     foreach (var investor in _investors)
     {
         _ibm.Attach(investor.Object);
     }
     Assert.AreEqual(0, _notifiedInvestors);
     _ibm.Price = 122;
     Assert.AreEqual(3, _notifiedInvestors);
     _notifiedInvestors = 0;
     _ibm.Detach(_investors.First().Object);
     _ibm.Price = 121;
     Assert.AreEqual(2, _notifiedInvestors);
 }
        public static void Main()
        {
            Stock ibm           = new IBM(nameof(IBM), 120.2);
            var   firstInvestor = new Investor(Constants.DisplayInvestor + 1);

            ibm.Attach(firstInvestor);
            ibm.Attach(new Investor(Constants.DisplayInvestor + 2));

            ibm.Price = 120.4;
            ibm.Detach(firstInvestor);
            ibm.Price = 125.58;
            ibm.Attach(new Investor(Constants.DisplayInvestor + 3));
            ibm.Price = 120.99;
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Stock ibm           = new IBM("IBM", 120.2);
            var   firstInvestor = new Investor("Investor #1");

            ibm.Attach(firstInvestor);
            ibm.Attach(new Investor("Investor #2"));

            ibm.Price = 120.4;
            ibm.Detach(firstInvestor);
            ibm.Price = 125.58;
            ibm.Attach(new Investor("Investor #3"));
            ibm.Price = 120.99;
        }
        public void Run()
        {
            // Skapa ibm-aktien
            IBM ibm = new IBM("IBM", 120.00);

            // En extra investor
            var myInvestor = new Investor("happybits");

            // Vi lägger till investerare
            ibm.Attach(new Investor("Sorros"));
            ibm.Attach(new Investor("Berkshire"));
            ibm.Attach(myInvestor);

            // När priset ändras så blir investorerna meddelade
            ibm.Price = 120.10;
            ibm.Price = 121.00;

            // Nu tar vi bort en investor och fortsätter ändra priset
            ibm.Detach(myInvestor);
            ibm.Price = 120.50;
            ibm.Price = 120.75;
        }