Exemple #1
0
        public void TestDefaults()
        {
            XDocument xDoc = null;

            #if NETFX_CORE
            var task = Windows.ApplicationModel.Package.Current.InstalledLocation.OpenStreamForReadAsync("Data\\Config.xml");

            xDoc = XDocument.Load(task.Result);
            #else
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Vici.Core.Test.Data.Config.xml"))
                xDoc = XDocument.Load(new XmlTextReader(stream));
            #endif
            InstanceXmlConfig config = new InstanceXmlConfig();

            ConfigManager configManager = new ConfigManager();

            configManager.Register(config);
            configManager.RegisterProvider(new ConfigurationProviderXmlConfig(xDoc));
            configManager.Update();

            Assert.AreEqual("test", config.SubGroupProp1.SubProp3);
            Assert.AreEqual("yeah", config.SubGroupProp1.SubProp4);
        }
Exemple #2
0
        public void TestStaticClassWithKey()
        {
            ConfigManager configManager = new ConfigManager();

            configManager.Register<StaticConfig2>();
            configManager.RegisterProvider(new ConfigurationProviderAppConfig());
            configManager.Update();

            Assert.AreEqual("xx2", StaticConfig2.Test1);
            Assert.AreEqual(88, StaticConfig2.SubObject1.TestInt1);
        }
Exemple #3
0
        public void TestStaticClassWithoutKey()
        {
            InstanceConfig config = new InstanceConfig();

            ConfigManager configManager = new ConfigManager();

            configManager.Register(config);
            configManager.Register<StaticConfig>();
            configManager.Register<StaticConfig2>();

            configManager.RegisterProvider(new ConfigurationProviderAppConfig());
            configManager.Update();

            Assert.AreEqual("xx1",StaticConfig.Test1);
            Assert.AreEqual(99, StaticConfig.SubObject1.TestInt1);

            Assert.AreEqual("xx2", StaticConfig2.Test1);
            Assert.AreEqual(88, StaticConfig2.SubObject1.TestInt1);

            Assert.AreEqual("xx1", config.Test1);
            Assert.AreEqual(99, config.SubObject1.TestInt1);

            Assert.IsNotNull(StaticConfig.IntValues);
            Assert.IsNotNull(StaticConfig.StringValues);

            Assert.AreEqual("x", StaticConfig.StringValues["ValX"]);
            Assert.AreEqual("y", StaticConfig.StringValues["ValY"]);
            Assert.AreEqual("z", StaticConfig.StringValues["ValZ"]);

            Assert.AreEqual(3, StaticConfig.StringValues.Count);

            Assert.AreEqual(1, StaticConfig.IntValues["Val1"]);
            Assert.AreEqual(2, StaticConfig.IntValues["Val2"]);
            Assert.AreEqual(3, StaticConfig.IntValues["Val3"]);

            Assert.AreEqual(3, StaticConfig.IntValues.Count);
        }
Exemple #4
0
        public void TestDefaults()
        {
            XDocument xDoc = null;

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Vici.Core.Test.Data.Config.xml"))
                xDoc = XDocument.Load(new XmlTextReader(stream));

            InstanceXmlConfig config = new InstanceXmlConfig();

            ConfigManager configManager = new ConfigManager();

            configManager.Register(config);
            configManager.RegisterProvider(new ConfigurationProviderXmlConfig(xDoc));
            configManager.Update();
           
            Assert.AreEqual("test", config.SubGroupProp1.SubProp3);
            Assert.AreEqual("yeah", config.SubGroupProp1.SubProp4);
        }