public override bool Equals(object obj) { this.trace += "->Equals;"; TestSimpleTracebleHashMapKey other = obj as TestSimpleTracebleHashMapKey; return(other != null && other.key == key); }
public void DefaultEqualityComparerTest1() { HashMap <TestSimpleTracebleHashMapKey, string> map = new HashMap <TestSimpleTracebleHashMapKey, string>(); TestSimpleTracebleHashMapKey key1 = new TestSimpleTracebleHashMapKey(1); TestSimpleTracebleHashMapKey key2 = new TestSimpleTracebleHashMapKey(2); map.Add(key1, "1"); map.Add(key2, "2"); Assert.AreEqual("->GetHashCode;", key1.Trace); Assert.AreEqual("->GetHashCode;->Equals;", key2.Trace); }
public void CustomEqualityComparerTest() { TestHashMapKeyEqualityComparer keyComparer = new TestHashMapKeyEqualityComparer(); HashMap <TestSimpleTracebleHashMapKey, string> map = new HashMap <TestSimpleTracebleHashMapKey, string>(17, keyComparer); TestSimpleTracebleHashMapKey key1 = new TestSimpleTracebleHashMapKey(1); TestSimpleTracebleHashMapKey key2 = new TestSimpleTracebleHashMapKey(2); map.Add(key1, "1"); map.Add(key2, "2"); StringAssertEx.IsNullOrEmpty(key1.Trace); StringAssertEx.IsNullOrEmpty(key2.Trace); Assert.AreEqual("->GetHashCode;->GetHashCode;->Equals;", keyComparer.Trace); }