/// <summary> /// Return the difference (changes, additions, but not removals) of /// property values between the supplied argument and the values /// contained in the collection. /// </summary> /// <param name="old">Another property values collection.</param> /// <returns> /// The collection of property values that are different than the supplied one. /// </returns> public IPropertyValues ChangesSince(IPropertyValues old) { MutablePropertyValues changes = new MutablePropertyValues(); if (old == this) { return(changes); } // for each property value in this (the newer set) foreach (PropertyValue newProperty in propertyValuesList) { PropertyValue oldProperty = old.GetPropertyValue(newProperty.Name); if (oldProperty == null) { // if there wasn't an old one, add it changes.Add(newProperty); } else if (!oldProperty.Equals(newProperty)) { // it's changed changes.Add(newProperty); } } return(changes); }
public void TestEquals() { PropertyValue one = new PropertyValue("Age", 12); PropertyValue two = new PropertyValue("Age", 12); Assert.AreEqual(one, two); Assert.AreEqual(one.GetHashCode(), two.GetHashCode()); Assert.AreEqual(one, one); Assert.IsFalse(one.Equals("Foo")); }
public void TestEquals() { PropertyValue one = new PropertyValue("Age", 12); PropertyValue two = new PropertyValue("Age", 12); Assert.AreEqual(one, two); Assert.AreEqual(one.GetHashCode(), two.GetHashCode()); Assert.AreEqual(one, one); Assert.IsFalse(one.Equals("Foo")); }