コード例 #1
0
ファイル: ConfigTest.cs プロジェクト: jcmm33/core
        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);
        }
 public ScrollingConfigGroup( ConfigManager configManager )
     : base(configManager)
 {
 }
コード例 #3
0
ファイル: ConfigTest.cs プロジェクト: jcmm33/core
        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);
        }
コード例 #4
0
ファイル: ConfigTest.cs プロジェクト: jcmm33/core
        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);
        }
コード例 #5
0
ファイル: ConfigTest.cs プロジェクト: TheMouster/core
        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);
        }
コード例 #6
0
        public void LatestDirConfigTest()
        {
            string dir1 = null;
            string dir2 = null;
            string prefix = Guid.NewGuid().ToString() + '-';
            string configFileName = null;
            string tempMsi = null;
            const string fileName = "testFile";

            try
            {
                // Create temp directories and files
                string tempPath = Path.GetTempPath() + prefix;
                dir1 = tempPath + "dir001" + '\\';
                Directory.CreateDirectory(dir1);
                File.CreateText(dir1 + fileName).Close();
                dir2 = tempPath + "dir002" + '\\';
                Directory.CreateDirectory(dir2);
                File.CreateText(dir2 + fileName).Close();
                tempMsi = Path.GetTempFileName();

                // Save config to disk
                Stream configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    "RemoteInstallUnitTests.TestConfigs.LatestDir.config");
                configFileName = Path.GetTempFileName();
                using (StreamReader sr = new StreamReader(configStream))
                {
                    File.WriteAllText(configFileName, sr.ReadToEnd());
                }

                // Check config
                NameValueCollection vars = new NameValueCollection();
                vars["temp"] = tempPath;
                vars["msi"] = tempMsi;
                ConfigManager config = new ConfigManager(configFileName, vars);
                Assert.AreEqual(config.Configuration.CopyFiles.Count, 1);
                Assert.AreEqual(config.Configuration.CopyFiles[0].File, dir2 + fileName);
            }
            finally
            {
                File.Delete(configFileName);
                File.Delete(tempMsi);
                Directory.Delete(dir1, true);
                Directory.Delete(dir2, true);
            }
        }