Add() public method

public Add ( string name ) : IConfig
name string
return IConfig
 public void NameAlreadyExists() {
     ConfigBase config1 = new ConfigBase("Test", null);
     ConfigBase config2 = new ConfigBase("Test", null);
     ConfigCollection collection = new ConfigCollection(null);
     collection.Add(config1);
     collection.Add(config2); // merges, no exception
 }
        public void AlreadyExistsException()
        {
            ConfigBase       config     = new ConfigBase("Test", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config);
            collection.Add(config); // exception
        }
        public void NameAlreadyExists()
        {
            ConfigBase       config1    = new ConfigBase("Test", null);
            ConfigBase       config2    = new ConfigBase("Test", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config1);
            collection.Add(config2); // merges, no exception
        }
        public void AddAndRemove() {
            ConfigBase config1 = new ConfigBase("Test", null);
            ConfigBase config2 = new ConfigBase("Another", null);
            ConfigCollection collection = new ConfigCollection(null);
            collection.Add(config1);
            collection.Add(config2);

            Assert.AreEqual(2, collection.Count);
            Assert.IsNotNull(collection["Test"]);
            Assert.IsNotNull(collection["Another"]);

            collection.Remove(config2);
            Assert.AreEqual(1, collection.Count);
            Assert.IsNotNull(collection["Test"]);
            Assert.IsNull(collection["Another"]);
        }
        public void GetConfig() {
            ConfigBase config1 = new ConfigBase("Test1", null);
            ConfigBase config2 = new ConfigBase("Test2", null);
            ConfigBase config3 = new ConfigBase("Test3", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config1);
            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(config1, collection[0]);

            collection.Add(config2);
            collection.Add(config3);
            Assert.AreEqual(3, collection.Count);

            Assert.AreEqual(config2, collection["Test2"]);
            Assert.AreEqual(config3, collection["Test3"]);
            Assert.AreEqual(config3, collection[2]);
        }
        public void AddAndRemove()
        {
            ConfigBase       config1    = new ConfigBase("Test", null);
            ConfigBase       config2    = new ConfigBase("Another", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config1);
            collection.Add(config2);

            Assert.AreEqual(2, collection.Count);
            Assert.IsNotNull(collection["Test"]);
            Assert.IsNotNull(collection["Another"]);

            collection.Remove(config2);
            Assert.AreEqual(1, collection.Count);
            Assert.IsNotNull(collection["Test"]);
            Assert.IsNull(collection["Another"]);
        }
        public void GetConfig()
        {
            ConfigBase       config1    = new ConfigBase("Test1", null);
            ConfigBase       config2    = new ConfigBase("Test2", null);
            ConfigBase       config3    = new ConfigBase("Test3", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config1);
            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(config1, collection[0]);

            collection.Add(config2);
            collection.Add(config3);
            Assert.AreEqual(3, collection.Count);

            Assert.AreEqual(config2, collection["Test2"]);
            Assert.AreEqual(config3, collection["Test3"]);
            Assert.AreEqual(config3, collection[2]);
        }
 public void AlreadyExistsException() {
     ConfigBase config = new ConfigBase("Test", null);
     ConfigCollection collection = new ConfigCollection(null);
     collection.Add(config);
     collection.Add(config); // exception
 }