public void TestEquality() { BOKey boKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol1); // Test when property count is different KeyDef keyDef = new KeyDef(); BOKey otherKey = new BOKey(keyDef); Assert.IsFalse(boKey == otherKey); // Same property count, but different prop names PropDef propDef1 = new PropDef("PropName5", typeof(string), PropReadWriteRule.ReadOnly, null); PropDef propDef2 = new PropDef("PropName6", typeof(string), PropReadWriteRule.ReadOnly, null); BOPropCol propCol = new BOPropCol(); propCol.Add(propDef1.CreateBOProp(false)); propCol.Add(propDef2.CreateBOProp(false)); keyDef.Add(propDef1); keyDef.Add(propDef2); otherKey = (BOKey)keyDef.CreateBOKey(propCol); Assert.IsFalse(boKey == otherKey); // Same props but different values (with one null) otherKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol2); otherKey["PropName"].Value = "blah"; Assert.IsFalse(boKey == otherKey); // Same props but different values (neither are null) otherKey = (BOKey)_keyDef1.CreateBOKey(_boPropCol2); boKey["PropName"].Value = "diblah"; Assert.IsFalse(boKey == otherKey); Assert.IsFalse(boKey.Equals(otherKey)); // False when different type of object Assert.IsFalse(boKey.Equals(keyDef)); // Finally, when they are equal boKey["PropName"].Value = "blah"; Assert.IsTrue(boKey == otherKey); Assert.IsTrue(boKey.Equals(otherKey)); }