Ejemplo n.º 1
0
        public void CanTrackDynamicObjectPropertyChanges()
        {
            dynamic dynamicObject = TrackableObjectFactory.CreateFrom(new TestDynamicObject());

            dynamicObject.Text  = "hello world 1";
            dynamicObject.Text  = "hello world 2";
            dynamicObject.Text2 = "hello world 3";
            ((TestDynamicObject)dynamicObject).DeclaredText = "hello world 4";
            ((TestDynamicObject)dynamicObject).DeclaredText = "hello world 5";

            IObjectChangeTracker          tracker  = ((object)dynamicObject).GetChangeTracker();
            IObjectPropertyChangeTracking tracking = tracker.GetDynamicTrackingByProperty("Text");

            Assert.AreEqual(2, tracker.ChangedProperties.Count);
            Assert.AreEqual("Text", tracking.PropertyName);
            Assert.AreEqual("hello world 1", tracking.OldValue);
            Assert.AreEqual("hello world 2", tracking.CurrentValue);
            Assert.AreEqual("hello world 1", ((object)dynamicObject).OldPropertyValue("Text"));
            Assert.AreEqual(null, ((TestDynamicObject)dynamicObject).OldPropertyValue(o => o.DeclaredText));
            Assert.AreEqual("hello world 2", ((object)dynamicObject).CurrentPropertyValue("Text"));
            Assert.AreEqual("hello world 5", ((TestDynamicObject)dynamicObject).CurrentPropertyValue(o => o.DeclaredText));
            Assert.IsTrue(((object)dynamicObject).PropertyHasChanged("Text"));
            Assert.IsFalse(((object)dynamicObject).PropertyHasChanged("Text2"));
        }
Ejemplo n.º 2
0
 public bool Equals(IObjectPropertyChangeTracking other) =>
 other != null && other.PropertyName == PropertyName;
Ejemplo n.º 3
0
 public bool Equals(IObjectPropertyChangeTracking other)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="targetObject">The object that changed</param>
 /// <param name="propertyChangeTracking">The property change tracking of the property that changed on the target object</param>
 public ObjectChangeEventArgs(object targetObject, IObjectPropertyChangeTracking propertyChangeTracking)
 {
     TargetObject           = targetObject;
     PropertyChangeTracking = propertyChangeTracking;
 }