public ConfigurationCollectionTest()
 {
     collRange = new ConfigurationCollection();
     collRange.Add( new DefaultConfiguration("collection", "ConfigurationCollectionTest") );
     collRange.Add( new DefaultConfiguration("collection", "ConfigurationCollectionTest") );
     collRange.Add( new DefaultConfiguration("collection", "ConfigurationCollectionTest") );
 }
        public void Add()
        {
            ConfigurationCollection collection = new ConfigurationCollection();
            collection.Add( new DefaultConfiguration( "test", "ConfigurationCollectionTest" ) );
            Assertion.AssertEquals( 1, collection.Count );
            Assertion.AssertEquals( "test", collection[0].Name );
            Assertion.AssertEquals( "ConfigurationCollectionTest" , collection[0].Location );

            collection.AddRange( arrayRange );
            Assertion.AssertEquals( 4, collection.Count );

            collection.AddRange( collRange );
            Assertion.AssertEquals( 7, collection.Count );

            int place = 0;
            foreach( IConfiguration config in collection )
            {
                Assertion.AssertEquals( "ConfigurationCollectionTest", config.Location );
                switch (place)
                {
                    case 0:
                        Assertion.AssertEquals( "test", config.Name );
                        break;

                    case 1:
                    case 2:
                    case 3:
                        Assertion.AssertEquals( "array", config.Name );
                        break;

                    case 4:
                    case 5:
                    case 6:
                        Assertion.AssertEquals( "collection", config.Name );
                        break;
                }
                place++;
            }
        }
        public void Index()
        {
            ConfigurationCollection collection = new ConfigurationCollection( arrayRange );
            DefaultConfiguration testconfig = new DefaultConfiguration( "test", "ConfigurationCollectionTest" );
            testconfig.Value = "1";
            collection.Add( testconfig );

            Assertion.AssertEquals( 4, collection.Count );
            IConfiguration config = collection[3]; // 0 based indexes

            Assertion.AssertEquals( "test", config.Name );
            Assertion.AssertEquals( "ConfigurationCollectionTest" , config.Location );

            Assertion.Assert( ! ("1" == collection[0].Value) );
            Assertion.AssertEquals( "1", collection[3].Value );
        }
        /// <summary>
        /// Return a collection of <see cref="IConfiguration"/>
        /// elements containing all node children with the specified name.
        /// </summary>
        /// <param name="name">The Name of the children to get.</param>
        /// <returns>
        /// The collection of <see cref="IConfiguration"/> children of
        /// this associated with the given name.
        /// </returns>
        public override ConfigurationCollection GetChildren(string name)
        {
            ConfigurationCollection result = new ConfigurationCollection();

            foreach (IConfiguration configuration in Children)
            {
                if (string.Compare(configuration.Name, name) == 0)
                {
                    result.Add(configuration);
                }
            }

            return result;
        }