public void Copy() { var keys = new object[245]; var values = new object[245]; for (int i = 0; i < 245; i++) { keys[i] = new object(); values[i] = new object(); } var indexes = new EntryIndex <object> [245]; for (int i = 0; i < 245; i++) { var key = keys[i]; var value = values[i]; FixedSizeDictionary.AddOrReplace(key, value, out var index); indexes[i] = index; Assert.True(FixedSizeDictionary.ContainsKey(index)); Assert.True(FixedSizeDictionary.ContainsKey(key)); Assert.True(FixedSizeDictionary.TryGetValue(key, out var actualValue)); Assert.Equal(value, actualValue); Assert.True(FixedSizeDictionary.TryGetValue(index, out actualValue)); Assert.Equal(value, actualValue); } var destination = new FixedSizeDictionary <object, object, EqualityComparers.ReferenceEqualityComparer <object> >(15, 17, new EqualityComparers.ReferenceEqualityComparer <object>()); FixedSizeDictionary.CopyTo(destination); FixedSizeDictionary.Clear(); for (int i = 0; i < 245; i++) { var key = keys[i]; var value = values[i]; destination.TryGetIndex(key, out var index); Assert.True(destination.ContainsKey(index)); Assert.True(destination.ContainsKey(key)); Assert.True(destination.TryGetValue(key, out var actualValue)); Assert.Equal(value, actualValue); Assert.True(destination.TryGetValue(index, out actualValue)); Assert.Equal(value, actualValue); } }