public void Disabling_Collection_Observation_Should_Suppress_Event()
        {
            //clear existing dependency and let the garbage collector take care of it
            //(works thanks to weak event listeners). If we didn't change listener remained active
            dependency = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //create settings and disable observations
            DependencyNodeSettings <ObservableCollection <Student> > settings;

            settings = new DependencyNodeSettings <ObservableCollection <Student> >(() => course.Students);
            settings.ChangeHandler          = OnDependencyChanged;
            settings.ObserveSubValueChanges = false;

            dependency = DependencyBuilder.CreateDependency(settings);

            //add student to collection
            course.Students.Add(TestUtil.CreateTestStudent());
            Assert.AreEqual(0, eventCounter);

            //remove student from collection
            course.Students.Remove(course.Students[7]);
            Assert.AreEqual(0, eventCounter);
        }
        public void Observing_Nullable_Types_Should_Work()
        {
            var basket = new { Course = c };

            DependencyBuilder.CreateDependency(() => basket.Course.IsFull, OnCourseChanged);

            c.IsFull = true;
            c.IsFull = null;
            c.IsFull = false;
            c.IsFull = true;

            Assert.AreEqual(4, changeCounter);
        }
        public void Sub_Property_Tracking_Can_Be_Disabled_Through_Settings()
        {
            //create settings class
            var settings = new DependencyNodeSettings <IAddress>(() => Student.School.Address);

            //configure settings to ignore sub item changes
            settings.ObserveSubValueChanges = false;

            //dispose old dependency in order to get rid of event listener!
            addressDependency.Dispose();
            addressDependency = DependencyBuilder.CreateDependency(settings);

            //does not cause a change event:
            Student.School.Address.City = "Ethon";
            Assert.AreEqual(0, changeCounter);
        }