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 ConfigCollectionEvents()
        {
            IniConfigSource source = new IniConfigSource();

            source.Configs.ConfigAdded +=
                new ConfigEventHandler(source_configAdded);
            source.Configs.ConfigRemoved +=
                new ConfigEventHandler(source_configRemoved);

            Assert.AreEqual(configAddedCount, 0);

            eventCollection = null;
            IConfig config = source.AddConfig("Test");

            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 1);
            Assert.AreEqual("Test", eventConfig.Name);

            eventCollection = null;
            config          = source.Configs.Add("Test 2");
            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 2);
            Assert.AreEqual("Test 2", eventConfig.Name);

            eventCollection = null;
            source.Configs.RemoveAt(0);
            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 2);
            Assert.AreEqual("Test", eventConfig.Name);
        }
 public void Setup()
 {
     eventConfig        = null;
     eventCollection    = null;
     configAddedCount   = 0;
     configRemovedCount = 0;
 }
        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 ConfigCollectionEvents() {
            IniConfigSource source = new IniConfigSource();
            source.Configs.ConfigAdded +=
                new ConfigEventHandler(source_configAdded);
            source.Configs.ConfigRemoved +=
                new ConfigEventHandler(source_configRemoved);

            Assert.AreEqual(configAddedCount, 0);

            eventCollection = null;
            IConfig config = source.AddConfig("Test");
            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 1);
            Assert.AreEqual("Test", eventConfig.Name);

            eventCollection = null;
            config = source.Configs.Add("Test 2");
            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 2);
            Assert.AreEqual("Test 2", eventConfig.Name);

            eventCollection = null;
            source.Configs.RemoveAt(0);
            Assert.IsTrue(source.Configs == eventCollection);
            Assert.AreEqual(configAddedCount, 2);
            Assert.AreEqual("Test", eventConfig.Name);
        }
 public void AlreadyExistsException() {
     ConfigBase config = new ConfigBase("Test", null);
     ConfigCollection collection = new ConfigCollection(null);
     collection.Add(config);
     collection.Add(config); // exception
 }
 private void source_configRemoved(object sender, ConfigEventArgs e) {
     configRemovedCount++;
     eventConfig = e.Config;
     eventCollection = (ConfigCollection)sender;
 }
 public void Setup() {
     eventConfig = null;
     eventCollection = null;
     configAddedCount = 0;
     configRemovedCount = 0;
 }
 protected ConfigSourceBase()
 {
     Alias    = new AliasText();
     AutoSave = false;
     Configs  = new ConfigCollection(this);
 }
 private void source_configRemoved(object sender, ConfigEventArgs e)
 {
     configRemovedCount++;
     eventConfig     = e.Config;
     eventCollection = (ConfigCollection)sender;
 }
Exemple #16
0
 protected ConfigSourceBase() {
     Alias = new AliasText();
     AutoSave = false;
     Configs = new ConfigCollection(this);
 }