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++;
            }
        }
 /// <summary>
 /// Creates a new instance of <c>ConfigurationCollection</c>.
 /// </summary>
 public ConfigurationCollection(ConfigurationCollection value)
 {
     this.AddRange(value);
 }
 /// <summary>
 /// Adds a <see cref="ConfigurationCollection"/>.
 /// </summary>
 /// <param name="value">The <see cref="ConfigurationCollection"/> to add.</param>
 public void AddRange(ConfigurationCollection value)
 {
     foreach(IConfiguration configuration in value)
     {
         this.Add(configuration);
     }
 }
        public void Constructors()
        {
            ConfigurationCollection collection = new ConfigurationCollection();
            Assertion.AssertEquals( 0, collection.Count );

            collection = new ConfigurationCollection( collRange );
            Assertion.AssertEquals( 3, collection.Count );
            foreach( IConfiguration config in collection )
            {
                Assertion.AssertEquals( "collection", config.Name );
                Assertion.AssertEquals( "ConfigurationCollectionTest", config.Location );
            }

            collection = new ConfigurationCollection( arrayRange );
            Assertion.AssertEquals( 3, collection.Count );
            foreach( IConfiguration config in collection )
            {
                Assertion.AssertEquals( "array", config.Name );
                Assertion.AssertEquals( "ConfigurationCollectionTest", config.Location );
            }
        }
        public void InsertRemove()
        {
            ConfigurationCollection collection = new ConfigurationCollection( arrayRange );
            IConfiguration config = new DefaultConfiguration( "test", "ConfigurationCollectionTest" );

            collection.Insert( 1, config );
            Assertion.Assert( collection.Contains( config ) );
            Assertion.AssertEquals( config, collection[1] );
            Assertion.AssertEquals( 4, collection.Count );

            collection.Remove( config );
            Assertion.AssertEquals( 3, collection.Count );
            Assertion.AssertEquals( false, collection.Contains( config ) );
        }
 public void IndexOf()
 {
     ConfigurationCollection collection = new ConfigurationCollection( arrayRange );
     Assertion.AssertEquals( 0, collection.IndexOf( arrayRange[0] ) );
     Assertion.AssertEquals( 2, collection.IndexOf( arrayRange[2] ) );
 }
        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 );
        }
        public void CopyTo()
        {
            ConfigurationCollection collection = new ConfigurationCollection( collRange );

            IConfiguration[] array = new IConfiguration[4];
            array[0] = new DefaultConfiguration( "test", "ConfigurationCollectionTest" );

            collection.CopyTo( array, 1 );

            bool isFirst = true;
            foreach ( IConfiguration config in array )
            {
                if (isFirst)
                {
                    Assertion.AssertEquals("test", config.Name);
                    isFirst = false;
                }
                else
                {
                    Assertion.AssertEquals("collection", config.Name);
                }

                Assertion.AssertEquals("ConfigurationCollectionTest", config.Location);
            }
        }
        public void Contains()
        {
            ConfigurationCollection collection = new ConfigurationCollection( arrayRange );

            foreach ( IConfiguration config in arrayRange )
            {
                Assertion.AssertEquals( true, collection.Contains( config ) );
            }

            foreach ( IConfiguration config in collRange )
            {
                Assertion.AssertEquals( false, collection.Contains( config ) );
            }
        }
        /// <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;
        }