Beispiel #1
0
        private void WireInterceptor(IBindableCollection <TElement> source)
        {
            _source = source;
            _source.CollectionChanged += _weakHandler.Handler;

            _propertyChangeObserver = new PropertyChangeObserver(Element_PropertyChanged);
            _addActioner            = new ElementActioner <TElement>(_source, element => _propertyChangeObserver.Attach(element), element => _propertyChangeObserver.Detach(element), Dispatcher);
        }
        public void can_clear_the_observed_changed()
        {
            var observable = new Observable();
            var observer = new PropertyChangeObserver<Observable>(observable);

            observable.OnPropertyChanged("Property");

            observer.ClearChanges();

            Assert.False(observer.HasChanged(x => x.Property));
        }
        public void can_determine_if_a_property_has_changed()
        {
            var observable = new Observable();
            var observer = new PropertyChangeObserver<Observable>(observable);

            Assert.False(observer.HasChanged("Property"));
            Assert.False(observer.HasChanged(x => x.Property));

            observable.OnPropertyChanged("Property");

            Assert.True(observer.HasChanged("Property"));
            Assert.True(observer.HasChanged(x => x.Property));
        }
        public void can_get_the_number_of_times_a_property_has_changed()
        {
            var observable = new Observable();
            var observer = new PropertyChangeObserver<Observable>(observable);

            Assert.Equal(0, observer.GetChangeCount("Property"));
            Assert.Equal(0, observer.GetChangeCount(x => x.Property));

            observable.OnPropertyChanged("Property");

            Assert.Equal(1, observer.GetChangeCount("Property"));
            Assert.Equal(1, observer.GetChangeCount(x => x.Property));

            observable.OnPropertyChanged("Property");

            Assert.Equal(2, observer.GetChangeCount("Property"));
            Assert.Equal(2, observer.GetChangeCount(x => x.Property));
        }