public void CopyTo_ArrayContainItemsWithHashTable_ReturnFalse() { CustomHashTable <int, char> hashTable = new CustomHashTable <int, char> { { 1, 't' }, { 2, 'y' }, { 4, 'i' }, { 5, 'c' }, { 6, 'r' }, { 13, 'o' } }; KeyValuePair <int, char>[] array = new KeyValuePair <int, char> [5]; array[0] = new KeyValuePair <int, char>(0, 'v'); try { hashTable.CopyTo(array, 1); Assert.IsTrue(true); } catch { Assert.IsFalse(false); } }
public void CopyTo_ArrayContainItemsWithHashTable_ReturnTrue() { CustomHashTable <int, char> hashTable = new CustomHashTable <int, char>(); KeyValuePair <int, char>[] array = new KeyValuePair <int, char> [100]; for (int i = 0; i < 100; i++) { hashTable.Add(i, i.ToString()[0]); } hashTable.CopyTo(array, 0); foreach (var item in array) { Assert.AreEqual(item.Value, hashTable[item.Key]); } }