public override Object Clone() { try { HashMap <K, V> map = (HashMap <K, V>)base.Clone(); map.elementCount = 0; map.elementData = NewElementArray(elementData.Length); map.PutAll(this); return(map); } catch (NotSupportedException) { return(null); } }
public void TestPutAll() { HashMap <Object, Object> hm2 = new HashMap <Object, Object>(); hm2.PutAll(hm); for (int i = 0; i < 1000; i++) { Assert.IsTrue(hm2.Get(i.ToString()).Equals((i)), "Assert.Failed to Clear all elements"); } Map <Object, Object> mockMap = new MockMap(); hm2 = new HashMap <Object, Object>(); hm2.PutAll(mockMap); Assert.AreEqual(0, hm2.Size(), "Size should be 0"); }
public void TestPutAllMockMapNull() { HashMap <Object, Object> hashMap = new HashMap <Object, Object>(); try { hashMap.PutAll(new MockMapNull()); Assert.Fail("Should throw NullReferenceException"); } catch (NullReferenceException) { } try { hashMap = new HashMap <Object, Object>(new MockMapNull()); Assert.Fail("Should throw NullReferenceException"); } catch (NullReferenceException) { } }