public void ConfigTest5Test() { ConfigTest5 configTest5 = ConfigManager.GetConfigClass <ConfigTest5>(); Assert.AreEqual(Constant.DefalutDataConverterTestValue1, configTest5.TestString); Assert.AreEqual(int.Parse(Constant.DefalutDataConverterTestValue2), configTest5.TestInt); Assert.AreEqual(long.Parse(Constant.DefalutDataConverterTestValue2), configTest5.TestLong); Assert.AreEqual(uint.Parse(Constant.DefalutDataConverterTestValue2), configTest5.TestUint); Assert.AreEqual(ulong.Parse(Constant.DefalutDataConverterTestValue2), configTest5.TestUlong); Assert.AreEqual(float.Parse(Constant.DefalutDataConverterTestValue3), configTest5.TestFloat); Assert.AreEqual(double.Parse(Constant.DefalutDataConverterTestValue3), configTest5.TestDouble); Assert.AreEqual(decimal.Parse(Constant.DefalutDataConverterTestValue3), configTest5.TestDecimal); Assert.AreEqual((DisconfNodeType)(int.Parse(Constant.DefalutDataConverterTestValue4)), configTest5.TestEnumInt); Assert.AreEqual(Enum.Parse(typeof(DisconfNodeType), Constant.DefalutDataConverterTestValue9, true), configTest5.TestEnumString); Assert.AreEqual((Guid)Guid.Parse(Constant.DefalutDataConverterTestValue5), configTest5.TestGuid); Assert.AreEqual((Type)Type.GetType(Constant.DefalutDataConverterTestValue6), configTest5.TestType); Assert.AreEqual((bool)bool.Parse(Constant.DefalutDataConverterTestValue7), configTest5.TestBool); Assert.AreEqual((char)char.Parse(Constant.DefalutDataConverterTestValue8), configTest5.TestChar); Assert.AreEqual((DateTime)DateTime.Parse(Constant.DefalutDataConverterTestValue10), configTest5.TestDateTime); Assert.IsNotNull(configTest5.TestStringList); Assert.AreEqual(2, configTest5.TestStringList.Count); Assert.AreEqual("host=127.0.0.1", configTest5.TestStringList[0]); Assert.AreEqual("port=81", configTest5.TestStringList[1]); Assert.IsNotNull(configTest5.TestStringDictionary); Assert.AreEqual(2, configTest5.TestStringDictionary.Count); Assert.AreEqual("127.0.0.1", configTest5.TestStringDictionary["Host"]); Assert.AreEqual("81", configTest5.TestStringDictionary["Port"]); _webApi.GetConfigItem("DefalutDataConverterTestValue1").Data = "Hello!"; ConfigStorageManager.ReloadConfigItem(new ConfigMetadataApiResult() { Name = "DefalutDataConverterTestValue1", UpdateTime = DateTime.Now.ToString(CultureInfo.InvariantCulture) }); Assert.AreEqual(Constant.DefalutDataConverterTestValue1, configTest5.TestString); ConfigTest5 newConfigTest5 = ConfigManager.GetConfigClass <ConfigTest5>(); Assert.AreEqual("Hello!", newConfigTest5.TestString); }
public void RedisConfigTest() { RedisConfig redisConfig = ConfigManager.GetConfigClass <RedisConfig>(); Assert.AreEqual("127.0.0.1", redisConfig.Host); Assert.AreEqual(81, redisConfig.Port); IDictionary <string, string> dictionary = ConfigManager.GetConfigValue <IDictionary <string, string> >("redis.properties"); Assert.IsNotNull(dictionary); Assert.AreEqual("127.0.0.1", dictionary.Get <string>("redis_host")); Assert.AreEqual(81, dictionary.Get <int>("redis_port")); _webApi.GetConfigItem("redis.properties").Data = "redis_host=192.168.1.10\r\nredis_port=82"; ConfigStorageManager.ReloadConfigItem(new ConfigMetadataApiResult() { Name = "redis.properties" }); redisConfig = ConfigManager.GetConfigClass <RedisConfig>(); Assert.AreEqual("192.168.1.10", redisConfig.Host); Assert.AreEqual(82, redisConfig.Port); }