public void EqualStringArrays() { var v1 = new string[] { "1", "2", "3" }; var v2 = new string[] { "1", "2", "3" }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void EqualByteArrays() { var v1 = new byte[] { 1, 2, 3 }; var v2 = new byte[] { 1, 2, 3 }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void NullValueComparison() { Assert.That(PropertyValueComparer.Compare(null, "x"), Is.False); Assert.That(PropertyValueComparer.Compare("x", null), Is.False); Assert.That(PropertyValueComparer.Compare(1, null), Is.False); Assert.That(PropertyValueComparer.Compare(null, null), Is.True); }
public void NotEqualStringArrays() { var v1 = new string[] { "1", "2", "3" }; var v2 = new string[] { "1", "2", "3", "4" }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.False); Assert.That(PropertyValueComparer.Compare(v2, v1), Is.False); }
public void NotEqualByteArrays() { var v1 = new byte[] { 1, 2, 3 }; var v2 = new byte[] { 1, 2, 3, 4 }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.False); Assert.That(PropertyValueComparer.Compare(v2, v1), Is.False); }
public void EqualDictionaryWithNulls() { var v1 = new Dictionary <byte, byte[]> { { 1, null } }; var v2 = new Dictionary <byte, byte[]> { { 1, null } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void EqualDictionary() { var v1 = new Dictionary <byte, string> { { 1, "1" }, { 2, "2" } }; var v2 = new Dictionary <byte, string> { { 1, "1" }, { 2, "2" } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void EqualHashtableWithNulls() { var v1 = new Hashtable { { 1, null }, { 2, 3 } }; var v2 = new Hashtable { { 1, null }, { 2, 3 } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void EqualHashtableWithByteArray() { var v1 = new Hashtable { { 1, new byte[] { 1, 2, 3 } } }; var v2 = new Hashtable { { 1, new byte[] { 1, 2, 3 } } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void EqualDictionaryWithByteArray() { var v1 = new Dictionary <byte, byte[]> { { 1, new byte[] { 1, 2, 3 } } }; var v2 = new Dictionary <byte, byte[]> { { 1, new byte[] { 1, 2, 3 } } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.True); }
public void NotEqualDictionary() { var v1 = new Dictionary <byte, string> { { 1, "1" }, { 2, "2" } }; var v2 = new Dictionary <byte, string> { { 1, "1" }, { 3, "3" } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.False); Assert.That(PropertyValueComparer.Compare(v2, v1), Is.False); }
public void NotEqualHashtableWithNulls() { var v1 = new Hashtable { { 1, null }, { 2, 3 } }; var v2 = new Hashtable { { 1, null }, { 3, 4 } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.False); Assert.That(PropertyValueComparer.Compare(v2, v1), Is.False); }
public void NotEqualDictionaryNulls() { var v1 = new Dictionary <byte, byte[]> { { 1, null } }; var v2 = new Dictionary <byte, byte[]> { { 1, new byte[] { 1, 2, 3, 4 } } }; Assert.That(PropertyValueComparer.Compare(v1, v2), Is.False); Assert.That(PropertyValueComparer.Compare(v2, v1), Is.False); }
private bool UpdateProperties(Hashtable props) { bool changed = false; foreach (DictionaryEntry entry in props) { object oldValue; if (this.properties.TryGetValue(entry.Key, out oldValue)) { if (entry.Value == null) { changed = true; this.properties.Remove(entry.Key); } else { if (oldValue == null || !PropertyValueComparer.Compare(oldValue, entry.Value)) { changed = true; this.properties[entry.Key] = entry.Value; } } } else { if (entry.Value != null) { changed = true; this.properties[entry.Key] = entry.Value; } } } return(changed); }