Ejemplo n.º 1
0
        public void TestPullObserver()
        {
            ICustomPullObservable<VegetableMarketPrice> vegMarketObservable = new VegetableMarketPullObservable();
              ICustomPullObserver<VegetableMarketPrice> homeObserver = new HomePullObserver(vegMarketObservable);
              ICustomPullObserver<VegetableMarketPrice> hotelObserver  = new HotelPullObserver(vegMarketObservable);

              homeObserver.ShowUpdates();
              hotelObserver.ShowUpdates();

              Console.WriteLine("Changing the price");
              vegMarketObservable.Update(new VegetableMarketPrice {OnionPrice = 10, PotatoPrice = 20, TomatoPrice = 30});
              homeObserver.ShowUpdates();
              hotelObserver.ShowUpdates();
        }
        public void TestPullObserver()
        {
            ICustomPullObservable <VegetableMarketPrice> vegMarketObservable = new VegetableMarketPullObservable();
            ICustomPullObserver <VegetableMarketPrice>   homeObserver        = new HomePullObserver(vegMarketObservable);
            ICustomPullObserver <VegetableMarketPrice>   hotelObserver       = new HotelPullObserver(vegMarketObservable);

            homeObserver.ShowUpdates();
            hotelObserver.ShowUpdates();

            Console.WriteLine("Changing the price");
            vegMarketObservable.Update(new VegetableMarketPrice {
                OnionPrice = 10, PotatoPrice = 20, TomatoPrice = 30
            });
            homeObserver.ShowUpdates();
            hotelObserver.ShowUpdates();
        }