public void ObjToObjLocateStressTest() { int numberOfIteration = 2000000; HashMap <BinaryArray, Int32> myHashMap = new HashMap <BinaryArray, Int32>(-1); Dictionary <BinaryArray, Int32> etalon = new Dictionary <BinaryArray, Int32>(); Random rand = new Random(55); for (int i = 0; i < numberOfIteration; ++i) { if (rand.Next(3) != 0) { BinaryArray ar = new BinaryArray().Assign(i); etalon[ar] = i; long iterator = myHashMap.LocateOrReserve(ar); myHashMap.SetKeyAt(iterator, ar); myHashMap.SetValueAt(iterator, i); Assert.AreEqual(myHashMap[ar], etalon[ar]); } else { int x = rand.Next(i); BinaryArray ar = new BinaryArray().Assign(x); Assert.AreEqual(etalon.ContainsKey(ar), myHashMap.ContainsKey(ar)); if (myHashMap.ContainsKey(ar)) { long key = myHashMap.Locate(ar); Assert.AreEqual(true, myHashMap.GetKeyAt(myHashMap.Locate(ar)).Equals(ar)); Assert.AreEqual(x, myHashMap.GetValueAt(myHashMap.Locate(ar))); myHashMap.RemoveAt(key); etalon.Remove(ar); } Assert.AreEqual(etalon.ContainsKey(ar), myHashMap.ContainsKey(ar)); } if (i % 1000000 == 0) { myHashMap.Clear(); etalon.Clear(); } } }