Ejemplo n.º 1
0
 public void TestNoConverts()
 {
     ExceptionAssert.Throws <ArgumentNullException>(() =>
     {
         var config = new global::CatLib.Config.Config(null, new CodeConfigLocator());
         config.Set("test", "test");
     });
 }
Ejemplo n.º 2
0
 public void NoLocatorTest()
 {
     ExceptionAssert.Throws <ArgumentNullException>(() =>
     {
         var config = new global::CatLib.Config.Config(new global::CatLib.Converters.Converters(), null);
         config.Set("test", "test");
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存测试
        /// </summary>
        public void SaveTest()
        {
            var converent = new global::CatLib.Converters.Converters();

            converent.AddConverter(new StringStringConverter());
            var config = new global::CatLib.Config.Config(converent, new CodeConfigLocator());

            config.Set("123", "abc");
            config.Save();
        }
Ejemplo n.º 4
0
        public void ExceptionConverterTest()
        {
            var converent = new global::CatLib.Converters.Converters();

            converent.AddConverter(new StringStringConverter());
            converent.AddConverter(new StringInt32Converter());
            var config = new global::CatLib.Config.Config(converent, new CodeConfigLocator());

            config.Set("123", "abc");
            Assert.AreEqual(0, config.Get("123", 0));
        }
Ejemplo n.º 5
0
        public void GetUndefinedTest()
        {
            var converent = new global::CatLib.Converters.Converters();

            converent.AddConverter(new StringStringConverter());
            var config = new global::CatLib.Config.Config(converent, new CodeConfigLocator());

            config.SetLocator(new CodeConfigLocator());
            config.Set("123", "123");

            Assert.AreEqual(null, config["222"]);
        }
Ejemplo n.º 6
0
        public void ConfigTest()
        {
            var converent = new global::CatLib.Converters.Converters();

            converent.AddConverter(new StringStringConverter());
            var config = new global::CatLib.Config.Config(converent, new CodeConfigLocator());

            config.SetConverters(converent);
            config.SetLocator(new CodeConfigLocator());

            Assert.AreEqual(null, config.Get <string>("test"));
            config.Set("test", "test");
            Assert.AreEqual("test", config.Get <string>("test"));

            config.Set("test", "222");
            Assert.AreEqual("222", config.Get <string>("test"));

            config.Save();
        }