private static void PutGetTestAssert(PersistentHashTable hashTable, byte[] key, byte[] value) { hashTable.Put(key, value); byte[] actual = hashTable.Get(key); TestHelper.AssertByteArraysAreSame(value, actual); }
private static void RemoveTestAssert(PersistentHashTable hashTable, int valueSize, byte[] key) { hashTable.Put(key, new byte[valueSize]); hashTable.Remove(key); try { hashTable.Get(key); } catch (KeyNotFoundException){} }
private static byte[] FillTableWithCollisions(int targetHashToCollideOn, PersistentHashTable hashTable) { byte[] collisionKey = new byte[] {0, 0, 0, 0}; for (int run = 0; run < hashTable.GetTableSize(); run++) { collisionKey = GetNextCollisionKey(targetHashToCollideOn, hashTable.GetTableSize(), collisionKey); hashTable.Put(collisionKey, new byte[] {0, 0, 0, (byte) run}); } //assert the table is full try { hashTable.Put(new byte[] { 255, 255, 255, 255 }, new byte[hashTable.GetValueSize()]); Assert.Fail("Should throw exception"); } catch (IndexOutOfRangeException) {} return collisionKey; }