public void IndexOfTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings());

            Assert.True(x.IndexOf(a) < 0);
            Assert.True(x.IndexOf(b) < 0);
            Assert.True(x.IndexOf(c) < 0);

            x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                    testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b);

            Assert.Equal(0, x.IndexOf(a));
            Assert.Equal(1, x.IndexOf(b));
            Assert.True(x.IndexOf(c) < 0);

            x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                    testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c);

            Assert.Equal(0, x.IndexOf(a));
            Assert.Equal(1, x.IndexOf(b));
            Assert.Equal(2, x.IndexOf(c));

            Assert.True(x.IndexOf(null) < 0);

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.IndexOf(a));
        }
        public void IndexerTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c);

            Assert.Equal(a, x[0].Value);
            Assert.Equal(b, x[1].Value);
            Assert.Equal(c, x[2].Value);

            Assert.Throws <NotImplementedException>(() => x[0].Value = c);

            var z = (IList <IChildElement>)x;

            Assert.Equal(a, z[0]);
            Assert.Equal(b, z[1]);
            Assert.Equal(c, z[2]);
            Assert.Throws <ArgumentOutOfRangeException>(() => z[5]);

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x[0]);
        }
        public void CopyToTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c);

            var array = new IChildElement[3];

            x.CopyTo(array, 0);

            Assert.Equal(a, array[0]);
            Assert.Equal(b, array[1]);
            Assert.Equal(c, array[2]);

            Assert.Throws <ArgumentOutOfRangeException>(() => x.CopyTo(array, 1));

            Assert.Throws <ArgumentOutOfRangeException>(() => x.CopyTo(array, -1));

            array = new IChildElement[2];

            Assert.Throws <ArgumentOutOfRangeException>(() => x.CopyTo(array, 0));

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.CopyTo(array, 0));
        }
        public void DisposeTests()
        {
            var testContext = _propertyTestData.GetContext();
            var x           = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                                  testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings());

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.IndexOf(null));
        }
        public void UntypedEnumeratorTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings());

            foreach (var item in (IEnumerable)x)
            {
                Assert.True(false);
            }

            x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                    testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c);

            var n = 0;

            foreach (IChildElement item in (IEnumerable)x)
            {
                switch (n++)
                {
                case 0:
                    Assert.Equal(a, item);
                    break;

                case 1:
                    Assert.Equal(b, item);
                    break;

                case 2:
                    Assert.Equal(c, item);
                    break;

                default:
                    Assert.True(false);
                    break;
                }
            }

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() =>
            {
                foreach (var y in (IEnumerable)x)
                {
                }

                ;
            });
        }
        public void InsertTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a);

            Assert.Throws <NotImplementedException>(() => x.Insert(1, b));

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.Insert(1, b));
        }
        public void ClearTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");
            var d           = testContext.GetChildElement("d");
            var x           = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                                  testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c, d);

            Assert.Equal(4, x.Count);

            Assert.Throws <NotImplementedException>(() => x.Clear());

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.Clear());
        }
        public void ContainsTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b);

            Assert.True(x.Contains(a));
            Assert.True(x.Contains(b));
            Assert.False(x.Contains(c));
            Assert.False(x.Contains(null));

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.Contains(a));
        }
        public void AddAndRetrieveTests()
        {
            var testContext = _propertyTestData.GetContext();
            var a           = testContext.GetChildElement("a");
            var b           = testContext.GetChildElement("b");
            var c           = testContext.GetChildElement("c");

            var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef,
                                                                        testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c);

            Assert.Equal(3, x.Count);

            Assert.Throws <NotImplementedException>(() => x.Add(a));

            var n = 0;

            foreach (var item in x)
            {
                switch (n++)
                {
                case 0:
                    Assert.Equal(a, item);
                    break;

                case 1:
                    Assert.Equal(b, item);
                    break;

                case 2:
                    Assert.Equal(c, item);
                    break;

                default:
                    Assert.True(false);
                    break;
                }
            }

            x.Dispose();
            Assert.Throws <ObjectDisposedException>(() => x.Add(a));
            Assert.Throws <ObjectDisposedException>(() => x.Count);
            Assert.Throws <ObjectDisposedException>(() => x[0]);
        }