public void CopyToTests() { var testContext = _propertyTestData.GetContext(); var x = new ConfigurationDictionary <IChildElement>(null, testContext.ChildConfigurationDictionaryPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); x.AddCopy("a", a); x.AddCopy("b", b); x.AddCopy("c", c); var array = new KeyValuePair <string, IChildElement> [3]; x.CopyTo(array, 0); Assert.Equal(a, array[0].Value, ConfigurationObjectComparer.Instance); Assert.Equal(b, array[1].Value, ConfigurationObjectComparer.Instance); Assert.Equal(c, array[2].Value, ConfigurationObjectComparer.Instance); Assert.Throws <ArgumentException>(() => x.CopyTo(array, 1)); Assert.Throws <ArgumentOutOfRangeException>(() => x.CopyTo(array, -1)); array = new KeyValuePair <string, IChildElement> [2]; Assert.Throws <ArgumentException>(() => x.CopyTo(array, 0)); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.CopyTo(array, 0)); }