Add() публичный Метод

public Add ( string name ) : IConfig
name string
Результат IConfig
Пример #1
0
 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
 }
Пример #2
0
        public void AlreadyExistsException()
        {
            ConfigBase       config     = new ConfigBase("Test", null);
            ConfigCollection collection = new ConfigCollection(null);

            collection.Add(config);
            collection.Add(config); // exception
        }
Пример #3
0
        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
        }
Пример #4
0
        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"]);
        }
Пример #5
0
        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]);
        }
Пример #6
0
        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"]);
        }
Пример #7
0
        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]);
        }
Пример #8
0
 public void AlreadyExistsException() {
     ConfigBase config = new ConfigBase("Test", null);
     ConfigCollection collection = new ConfigCollection(null);
     collection.Add(config);
     collection.Add(config); // exception
 }