public void CanTrackSimplePropertyChanges()
        {
            const string initialValue = "hello world";
            const string changedValue = "hello world 2";

            A a = TrackableObjectFactory.CreateFrom(new A {
                Text = initialValue
            });

            a.Text = changedValue;

            Assert.AreNotEqual(initialValue, a.Text);
            Assert.AreEqual(changedValue, a.Text);

            IObjectChangeTracker changeTracker = a.GetChangeTracker();

            Assert.AreEqual(1, changeTracker.ChangedProperties.Count);
            Assert.AreEqual(1, changeTracker.UnchangedProperties.Count);

            IDeclaredObjectPropertyChangeTracking tracking = changeTracker.ChangedProperties.OfType <IDeclaredObjectPropertyChangeTracking>().Single();

            Assert.AreEqual("Text", tracking.Property.Name);
            Assert.AreEqual(initialValue, tracking.OldValue);
            Assert.AreEqual(changedValue, tracking.CurrentValue);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="targetObject">The object that changed</param>
 /// <param name="propertyChangeTracking">The property change tracking of the declared property that changed on the target object</param>
 public DeclaredObjectPropertyChangeEventArgs(object targetObject, IDeclaredObjectPropertyChangeTracking propertyChangeTracking)
     : base(targetObject, propertyChangeTracking)
 {
     _graphTrackingInfo = new Lazy <IObjectGraphTrackingInfo>
                          (
         () => propertyChangeTracking.Tracker.GetTrackingGraphFromProperty(propertyChangeTracking.Property)
                          );
 }
Example #3
0
        public override bool Equals(object obj)
        {
            IDeclaredObjectPropertyChangeTracking declared = obj as IDeclaredObjectPropertyChangeTracking;

            if (declared != null)
            {
                return(Equals(declared));
            }
            else
            {
                return(Equals(obj as IObjectPropertyChangeTracking));
            }
        }
        public void ExceptWith(IEnumerable <T> other)
        {
            IDeclaredObjectPropertyChangeTracking tracking = ChangeContext.Collection.GetPropertyTracking(ChangeContext.ParentObjectProperty);

            IEnumerable <object> itemsToRemove = (IEnumerable <object>)other;

            ChangeContext.AddedItems.ExceptWith(itemsToRemove);

            foreach (object item in itemsToRemove.Intersect((IEnumerable <object>)tracking.OldValue))
            {
                ChangeContext.AddedItems.Add(item);
            }

            EvalCollectionChange();
        }
Example #5
0
 public bool Equals(IDeclaredObjectPropertyChangeTracking other) =>
 other != null && other.Property == Property;
Example #6
0
 public bool Equals(IDeclaredObjectPropertyChangeTracking other)
 {
     throw new NotImplementedException();
 }