Пример #1
0
        public void ConfigUnitSettingTest()
        {
            var config = new CatLib.Config.Config();

            config.AddConverter(typeof(string), new StringStringConverter());
            config.AddLocator(new UnitySettingLocator());

            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();
        }
Пример #2
0
 public void TestNoConverts()
 {
     ExceptionAssert.Throws <ArgumentNullException>(() =>
     {
         var config = new CatLib.Config.Config(null, new CodeConfigLocator());
         config.Set("test", "test");
     });
 }
Пример #3
0
        /// <summary>
        /// 保存测试
        /// </summary>
        public void SaveTest()
        {
            var config = new CatLib.Config.Config();

            config.AddLocator(new CodeConfigLocator());
            config.Set("123", "abc");
            config.Save();
        }
Пример #4
0
        public void GetWithUndefinedTypeConverterTest()
        {
            var config = new CatLib.Config.Config();

            config.AddLocator(new CodeConfigLocator());
            config.Set("123", "123");
            Assert.AreEqual(null, config.Get <ConfigTests>("123"));
        }
Пример #5
0
 public void NoLocatorTest()
 {
     ExceptionAssert.Throws <ArgumentNullException>(() =>
     {
         var config = new CatLib.Config.Config(new CatLib.Converters.Converters(), null);
         config.Set("test", "test");
     });
 }
Пример #6
0
        public void GetUndefinedTest()
        {
            var config = new CatLib.Config.Config();

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

            Assert.AreEqual(null, config["222"]);
        }
Пример #7
0
        public void NoLocatorTest()
        {
            var config = new CatLib.Config.Config();

            ExceptionAssert.Throws <RuntimeException>(() =>
            {
                config.Set("test", "test");
            });
        }
Пример #8
0
        public void CanNotFindCoverterTest()
        {
            var config = new CatLib.Config.Config();

            config.AddLocator(new CodeConfigLocator());
            ExceptionAssert.Throws <ConverterException>(() =>
            {
                config.Set("123", new ConfigTests());
            });
        }
Пример #9
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();
        }
Пример #10
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();
        }
Пример #11
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));
        }
Пример #12
0
        public void ExceptionConverterTest()
        {
            var config = new CatLib.Config.Config();

            config.AddLocator(new CodeConfigLocator());
            config.Set("123", "abc");

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                Assert.AreEqual(null, config.Get("123", 0));
            });
        }
Пример #13
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"]);
        }