Exemplo n.º 1
0
        public void UnSubscribeWorksFine()
        {
            var subscriber  = new BubbleTestClass();
            var subcsriber2 = new BubbleTestClass();


            var publisher = new TestPublisher();

            //setup a subscriber
            subscriber.PublicField = publisher;

            //set another subscriber to mess with the first
            subcsriber2.PublicField = publisher;

            //overwrite the field
            subscriber.PublicField = new TestPublisher();

            //the subscriber should not be notified of changes in the old value
            ((INotifyPropertyChanged)subscriber).PropertyChanged +=
                (s, e) => Assert.Fail("Shouldt not fire. UnSubscription failed");

            //action! change the publisher.
            publisher.Name = "new";
        }
        public void UnSubscribeWorksFine()
        {
            var subscriber = new BubbleTestClass();
            var subcsriber2 = new BubbleTestClass();

            
            var publisher = new TestPublisher();
            //setup a subscriber
            subscriber.PublicField = publisher;

            //set another subscriber to mess with the first
            subcsriber2.PublicField = publisher;

            //overwrite the field
            subscriber.PublicField = new TestPublisher();

            //the subscriber should not be notified of changes in the old value
            ((INotifyPropertyChanged)subscriber).PropertyChanged += 
                (s, e) => Assert.Fail("Shouldt not fire. UnSubscription failed");

            //action! change the publisher.
            publisher.Name = "new";
        }