Esempio n. 1
0
        /// <summary>
        /// 保存测试
        /// </summary>
        public void SaveTest()
        {
            var converent = new CatLib.Converters.Converters();

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

            config.Set("123", "abc");
            config.Save();
        }
Esempio n. 2
0
        public void ExceptionConverterTest()
        {
            var converent = new CatLib.Converters.Converters();

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

            config.Set("123", "abc");
            Assert.AreEqual(0, config.Get("123", 0));
        }
Esempio n. 3
0
        public void GetUndefinedTest()
        {
            var converent = new CatLib.Converters.Converters();

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

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

            Assert.AreEqual(null, config["222"]);
        }
Esempio n. 4
0
        public void ConfigTest()
        {
            var converent = new CatLib.Converters.Converters();

            converent.AddConverter(new StringStringConverter());
            var config = new 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();
        }
Esempio n. 5
0
        public void WatchTest()
        {
            var configManager = App.Make <IConfigManager>();

            configManager.SetDefault("catlib");
            configManager.Extend(() =>
            {
                var convert = new CatLib.Converters.Converters();
                convert.AddConverter(new StringStringConverter());
                return(new CatLib.Config.Config(convert, new CodeConfigLocator()));
            });

            var watchValue = string.Empty;

            configManager.Default.Watch("watch", (value) =>
            {
                watchValue = value.ToString();
            });

            configManager.Default.Set("watch", "123");
            configManager.Default.Set("nowatch", "333");

            Assert.AreEqual("123", watchValue);
        }