示例#1
0
        public ConfigBase(string name, IConfigSource source)
        {
            _configName  = name;
            ConfigSource = source;

            Alias = new AliasText();
        }
示例#2
0
        public void NonExistantBooleanText() {
            AliasText alias = new AliasText();
            alias.AddAlias("true", true);
            alias.AddAlias("faLSe", false);

            Assert.IsTrue(alias.GetBoolean("Not present"));
        }
示例#3
0
        public void GetIntNonExistantKey()
        {
            AliasText alias = new AliasText();

            alias.AddAlias("error code", "WaRn", 100);

            Assert.AreEqual(100, alias.GetInt("not exist", "warn"));
        }
示例#4
0
        public void GetDefaultAliases() {
            AliasText alias = new AliasText();

            Assert.IsTrue(alias.ContainsBoolean("true"));
            Assert.IsTrue(alias.ContainsBoolean("false"));

            Assert.IsTrue(alias.GetBoolean("tRUe"));
            Assert.IsFalse(alias.GetBoolean("FaLse"));
        }
示例#5
0
        public void NonExistantBooleanText()
        {
            AliasText alias = new AliasText();

            alias.AddAlias("true", true);
            alias.AddAlias("faLSe", false);

            Assert.IsTrue(alias.GetBoolean("Not present"));
        }
示例#6
0
        public void GetDefaultAliases()
        {
            AliasText alias = new AliasText();

            Assert.IsTrue(alias.ContainsBoolean("true"));
            Assert.IsTrue(alias.ContainsBoolean("false"));

            Assert.IsTrue(alias.GetBoolean("tRUe"));
            Assert.IsFalse(alias.GetBoolean("FaLse"));
        }
示例#7
0
        public void GetInt() {
            AliasText alias = new AliasText();

            Assert.IsFalse(alias.ContainsInt("error code", "warn"));
            Assert.IsFalse(alias.ContainsInt("error code", "error"));
            alias.AddAlias("error code", "WaRn", 100);
            alias.AddAlias("error code", "ErroR", 200);

            Assert.IsTrue(alias.ContainsInt("error code", "warn"));
            Assert.IsTrue(alias.ContainsInt("error code", "error"));

            Assert.AreEqual(100, alias.GetInt("error code", "warn"));
            Assert.AreEqual(200, alias.GetInt("error code", "ErroR"));
        }
示例#8
0
        public void GetBoolean() {
            AliasText alias = new AliasText();

            Assert.IsFalse(alias.ContainsBoolean("on"));
            Assert.IsFalse(alias.ContainsBoolean("off"));
            alias.AddAlias("oN", true);
            alias.AddAlias("oFF", false);

            Assert.IsTrue(alias.ContainsBoolean("oN"));
            Assert.IsTrue(alias.ContainsBoolean("off"));

            Assert.IsTrue(alias.GetBoolean("oN"));
            Assert.IsFalse(alias.GetBoolean("OfF"));
        }
示例#9
0
        public void GetInt()
        {
            AliasText alias = new AliasText();

            Assert.IsFalse(alias.ContainsInt("error code", "warn"));
            Assert.IsFalse(alias.ContainsInt("error code", "error"));
            alias.AddAlias("error code", "WaRn", 100);
            alias.AddAlias("error code", "ErroR", 200);

            Assert.IsTrue(alias.ContainsInt("error code", "warn"));
            Assert.IsTrue(alias.ContainsInt("error code", "error"));

            Assert.AreEqual(100, alias.GetInt("error code", "warn"));
            Assert.AreEqual(200, alias.GetInt("error code", "ErroR"));
        }
示例#10
0
        public void GetBoolean()
        {
            AliasText alias = new AliasText();

            Assert.IsFalse(alias.ContainsBoolean("on"));
            Assert.IsFalse(alias.ContainsBoolean("off"));
            alias.AddAlias("oN", true);
            alias.AddAlias("oFF", false);

            Assert.IsTrue(alias.ContainsBoolean("oN"));
            Assert.IsTrue(alias.ContainsBoolean("off"));

            Assert.IsTrue(alias.GetBoolean("oN"));
            Assert.IsFalse(alias.GetBoolean("OfF"));
        }
示例#11
0
        public void GetIntEnum()
        {
            AliasText alias = new AliasText();

            alias.AddAlias("node type", new System.Xml.XmlNodeType());

            Assert.AreEqual((int)System.Xml.XmlNodeType.Text,
                            alias.GetInt("node type", "teXt"));
            Assert.AreEqual((int)System.Xml.XmlNodeType.Attribute,
                            alias.GetInt("node type", "aTTribute"));

            try {
                alias.GetInt("node type", "not here");
            }
            catch {}
        }
示例#12
0
        public void GetIntEnum() {
            AliasText alias = new AliasText();
            alias.AddAlias("node type", new System.Xml.XmlNodeType());

            Assert.AreEqual((int)System.Xml.XmlNodeType.Text,
                            alias.GetInt("node type", "teXt"));
            Assert.AreEqual((int)System.Xml.XmlNodeType.Attribute,
                            alias.GetInt("node type", "aTTribute"));

            try {
                alias.GetInt("node type", "not here");
            }
            catch {}
        }
示例#13
0
        public void GetIntNonExistantKey() {
            AliasText alias = new AliasText();
            alias.AddAlias("error code", "WaRn", 100);

            Assert.AreEqual(100, alias.GetInt("not exist", "warn"));
        }
示例#14
0
 protected ConfigSourceBase()
 {
     Alias    = new AliasText();
     AutoSave = false;
     Configs  = new ConfigCollection(this);
 }
示例#15
0
        public ConfigBase(string name, IConfigSource source) {
            _configName = name;
            ConfigSource = source;

            Alias = new AliasText();
        }
示例#16
0
 protected ConfigSourceBase() {
     Alias = new AliasText();
     AutoSave = false;
     Configs = new ConfigCollection(this);
 }